So I'm building a custom theme, which I like to be translation ready.
I have a string with a variable, so I do something like
<?php
echo __('This collection contains %s items.', $numItems);
?>
But since $numItems
might be '1', I would like to modify the string so it echos 'item' (singular) instead of 'items' (plural).
In WordPress there is a function _n()
for this. How could I acomplish this in Omeka?
You might have to just do a check on $numItems
:
<?php if ($numItems == 1) {
echo __('This collection contains %s item.', $numItems);
} else {
echo __('This collection contains %s items.', $numItems);
}
Hey Patrick,
Thanx. yes, that was my back up plan. Just wondering if there was a nicer/ better way.
Thanx!
There's no better option with the current version, but there is an active pull request that aims to add a mechanism for allowing plurals in translations. I think you can look forward to seeing it or something like it in a future release.