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

JS implementation of trans_choice doesn't match PHP implementation #35

Open
marijnvdwerf opened this issue Mar 7, 2022 · 1 comment

Comments

@marijnvdwerf
Copy link

Found out that (simplified) trans_choice(":count messages", 2) throws an error, while Laravel itself is fine with it. Did a bit of digging, and found that there's various cases where I18n.js behaves differently from the framework.

Testcases: https://jsbin.com/ruzaceyawo/edit?js,output
Laravel Framework testcase: https://github.com/laravel/framework/blob/9.x/tests/Translation/TranslationMessageSelectorTest.php

Another (seperate) issue is the "default pluralisation" rules are based on the en locale. Others can have more entries, and different rules.

E.g.

public function getPluralIndex($locale, $number)
    // ...
    case 'uk':   
        return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
    // ...
}
@iamgergo
Copy link
Member

Hi, thanks for the report!

Yes I see. I'm not sure I could fix this quickly.

Are you planning to make a PR? We could start with one language and then we could extend it.

What do you think?

Thanks!

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