Closed kmudrick closed 8 years ago
Good point. I wonder what the best approach would be here. Maybe smart_count
, smart_count_2
, ..., smart_count_N
?
Its been a while, any update on this issue as it would be better than doing multiple statements?
Then you'd need 9 translations for a Russian sentence with two counts in it =P
in french, 0 is singular, ex. "0 car", is there a way to achieve this with polyglot ?
This request, er, is not what anybody wants, ever :).
Let's say you're trying to translate this:
I bought 1 banana and 2 carrots
Then you should use phrases like this:
{
"nCarrots": "%{smart_count} carrot |||| %{smart_count} carrots",
"nBananas": "%{smart_count} banana |||| %{smart_count} bananas",
"sentence": "I bought %{bananas} and %{carrots}"
}
And you'd call it like this:
var carrots = polyglot.t('nCarrots', 2);
var bananas = polyglot.t('nBananas', 1);
var sentence = polyglot.t('sentence', { bananas: bananas, carrots: carrots });
This is easier to translate, and it makes more sense than combinations. Think of your poor Arabic translator: would you honestly expect him/her to translate all 36 possible combinations of smart_count
and smart_count_2
?
@adamhooper great approach! Closing this issue as that is the accepted way of handling this.
The pluralization support seems really limited if it only supports a single "smart_count" interpolated value. The only other option as currently implemented seems to be to string multiple phrases together and concatenate them, which seems tedious and messy.