formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

intlMessage with some locales always returns plural #65

Closed alex-seville closed 9 years ago

alex-seville commented 9 years ago

If I have a zh-Hant-HK string like:

"TOTAL_DISCUSSIONS = {count, plural, one {1 個討論於} other {# WRONG}}"

and pass in any value (including 1) I always get "# WRONG" as the result.

This works for other locals, like en-US, fr-FR, es-MX, de-DE, it-IT, pt-BR.

It DOES NOT work for locales like zh-Hant-HK, vi-VN, ko-KR

ericf commented 9 years ago

Chinese locales don't have a concept of pluralization, all numeric values are always other, so this is working correctly. There's no "singular" concept in these languages.

alex-seville commented 9 years ago

Here's a better example:

in English: "TITLE_PLACEHOLDER = {selectedCount, plural, one {Change title} other {Change all titles}}" In Chinese: "TITLE_PLACEHOLDER = {selectedCount, plural, one {變更標題} other {變更所有標題}}"

How can we handle this situation without pluralization?

ericf commented 9 years ago

You would use the =1 selector instead of one to "force" it, but you'd want to check with native speaker to to know, given this context, what's appropriate. It's likely to be a single phrase for all values, in which case you won't need a plural argument for this.

alex-seville commented 9 years ago

so we'd use:

"TITLE_PLACEHOLDER = {selectedCount, plural, =1 {變更標題} other {變更所有標題}}" ?

alex-seville commented 9 years ago

this was sent to us by our translation team, so I suspect that they think it is appropriate to use for a single value, but I'll double check.

ericf commented 9 years ago

I couldn't say since I don't know Chinese. But using =1 will have precedence for selectCount values of 1. Any =* values are checked first for exact matches.

alex-seville commented 9 years ago

Ok, thanks.