Skip to content
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

ng-pluralization and usage with languages of different numbers of plural modes #34

Open
brycecr opened this issue Mar 2, 2015 · 2 comments

Comments

@brycecr
Copy link
Contributor

brycecr commented Mar 2, 2015

I was thinking about ng-pluralize and angular-localization in the case where we have a phrase that is translated into two languages with different number of plural modes.

E.g., in english, we just want to use the simple rule one / other:

<ng-pluralize data-count="numCount" data-when="{ '1': '{{ 'one': '{{ plurals.one | i18n }}', 'other': '{{ plurals.other | i18n }}' }" ></ng-pluralize>

But if I then want translate to, say, russian, then the number of rules i need changes to 4 to something like:

<ng-pluralize data-count="numCount" data-when="{ '1': '{{ 'one': '{{ plurals.one | i18n }}', 'other': '{{ plurals.other | i18n }}', 'few': {{ plurals.few | i18n }}, 'many':'{{ plurals.many | i18n }}' }" ></ng-pluralize>

However, I've already hardcoded the number of rules by setting them in the when attribute as such, so just translating the one and other options from the english version isn't enough to implement the above.

So, what I'd really like to so is something like:

<span data-count="numCount" data-i18n-plural="pluralMsg"></span>

And then provide, in the translation for pluralMsg, a plural-sensitive string. This is the way it's handled in ICU format (e.g. formatjs and I can see why -- it makes a lot more sense to have the translator figure out the correct pluralization rules in the yaml/json file then to have devs set the plural branching.

This leads me to few questions:

  • Am I correct in saying this is a problem?
  • What is the best way to handle this in ngLocalize currently?
  • If the answer to the above isn't the way we want this to work, how can we change ngLocalize to handle this better?

Thanks!

@brycecr
Copy link
Contributor Author

brycecr commented Mar 11, 2015

This is essentially the same as issue #16

@thenikso
Copy link

What I do for the moment is something like:

<any i18n="common.key-{{ myCount==1&&'signle'||'plural' }}" data-count="{{ myCount }}">

Which works just fine for a single/plural case avoiding filters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants