Open cojack opened 8 years ago
I have the same issue as I use en_US, fr_FR etc language codes.
The plural forms match is based on the first part of the code, the plural rules should be matched using the first part of the locale, like language.split('_')[0]
.
@rubenv bump
@rubenv why you don't extract the plural form from .po files? Instead you creating your gettextPlurals factory?
Because we don't want to include a parser for arbitrary expressions (or worse: eval).
I'd love to have this in, but it's not very high on our list of priorities right now on the project that I work on (we currently don't use sublanguage codes). Will gladly merge a patch for it though, just be sure to include a unit test.
@cojack I've added simple fix for the issue could you update your angular-gettext to master or v2.3.1 and let me know if it fixes your problems?
@IShotTheSheriff Thank you for your fix to support language codes with locale. But why was add support for format with separator ''_"? At this wiki page https://en.wikipedia.org/wiki/Language_code default separator is "-". And looks like it's the ISO standard.
Please, look and fix or add support for both language codes "en-US" and "en_US".
@aprocom The convention when specifying locales in programming environments is an underscore, which you can verify by running locale
on a unix machine:
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
....
But yeah, it makes sense to support both versions, should be a trivial fix.
@rubenv please look at pull request https://github.com/rubenv/angular-gettext/pull/309
If you translate strings to POSIX standard like: "en_US", "en_GB", "pl_PL" etc... Then you will never get an correct plural based on .po files. fe:
singular:
plural:
In polish, it'll be:
Then, when you translate it by poedit, you create an file with language: pl_PL in application I use pl_PL, and everytime i got form 1 or 0 if N is singular.
In the method getStringFormFor you should use
or in gettextPlurals you should use fallback language.
Btw, @rubenv why you don't extract the plural form from .po files? Instead you creating your gettextPlurals factory?