-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support language-specific pluralization #7991
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like iD uses Ruby-style YAML, so Transifex should recognize the one
and other
subkeys as plural rules. 👍
for (let k in replacements) { | ||
const token = `{${k}}`; | ||
const regex = new RegExp(token, 'g'); | ||
result = result.replace(regex, replacements[k]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a good place to apply some number formatting both for grouping characters (really big changesets!) and non-European numerals (for languages like Arabic and Hindi).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this is why I left strings like {n} result for {search}
instead of 1 result for {search}
. I think I'll add formatting separately though.
@1ec5 Yep, I made the changes with that documentation in mind. I'll debug if Transifex doesn't pick it up for some reason. |
@1ec5 Do you know if we need to enable plural forms for strings like this that are based on an amount but don't include the amount?
|
It's not necessary when there is no numeral. |
Closes #597.
This is essentially a reimplementation of #4964 (shout-out to @1ec5!), but for the current codebase.
We can also use the built-in
Intl.PluralRules
function instead of an external dependency, since it's now supported in all major browsers. iD will attempt to fallback gracefully on legacy browsers.