-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better i18n plural support #597
Comments
Doesn't seem to be critical. |
I would like to see this re-assessed, and maybe flagged "help wanted" from someone fluent in internationalization stuff. |
Sure @althio we can reopen and ask for help. I agree that it's not critical, but if somebody wants to work on it, I'd accept a PR for it. In some places we support pluralization just by having multiple translation strings: Lines 80 to 103 in c8e89b7
|
Thanks @bhousel
There are shortcomings with this simple approach and maybe a systematic approach would be better (but more complex). |
Thats fine, but I'd strongly prefer "simple" over "perfect".. If we need to redo all of our translations and the code to produce them to get to "perfect", lets not do that. |
Some of the supported languages pluralize according to more complex rules that couldn’t be accommodated by adding a few extra strings for translation. For example, some languages have a different plural form for numbers ending in 1. I think it would be a reasonable goal to support each of iD’s languages as a first-class citizen, but doing so by adding strings would unnecessarily increase the workload for all translators. For example, a Spanish translator shouldn’t have to translate redundant strings because Russian has a dual form. The good news is that Transifex supports alternatives to the YAML format that explicitly handle pluralization. (I’m familiar with .stringsdict from iOS development, but there are others.) We could supplement the existing YAML file with another file containing a few override strings for which pluralization matters. For languages like Chinese that have no plural forms, there would only be one set of strings to translate. Back here in this repository, iD could depend on one of several libraries that support the CLDR plural format. |
Turns out Transifex supports plurals in YAML as well, as subkeys of what would normally be a single string. To enable Transifex pluralization for a particular message, we need to turn something like: Line 295 in d60c423
into: changes:
one: "1 Change"
other: "%{count} Changes" That’ll cause Transifex to display a tabbed interface for this message. Some languages will see a different set of tabs than the To use the pluralized translations, we’d need a library such as the Plural module of globalize.js – there are several alternatives – to determine which rule ( Line 36 in d60c423
Someday we’ll be able to use It’s unclear to me how or whether this Rails-style YAML format supports pluralizing multiple placeholders within a single message, as gettext and stringsdict can. This is the only message that currently contains multiple pluralized words: Line 570 in d60c423
I think we could break it up into multiple messages as a workaround. |
Introduced dependencies on cldr-core and CLDRPluralRuleParser, which supply the plural rules and plural rule parsing, respectively. When looking up a translation and one of the tokens is numeric, look one level deeper in the translation file for plural forms. Fixes #597.
#4964 implements this enhancement. |
Introduced dependencies on cldr-core and CLDRPluralRuleParser, which supply the plural rules and plural rule parsing, respectively. When looking up a translation and one of the tokens is numeric, look one level deeper in the translation file for plural forms. Fixes #597.
Introduced dependencies on cldr-core and CLDRPluralRuleParser, which supply the plural rules and plural rule parsing, respectively. When looking up a translation and one of the tokens is numeric, look one level deeper in the translation file for plural forms. Fixes #597.
Multiselect produces translations like "Deleted {n} objects", which we're currently translating without real plural form support.
The text was updated successfully, but these errors were encountered: