i18n icon indicating copy to clipboard operation
i18n copied to clipboard

JS implementation of trans_choice doesn't match PHP implementation

Open marijnvdwerf opened this issue 3 years ago • 1 comments

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);
    // ...
}

marijnvdwerf avatar Mar 07 '22 17:03 marijnvdwerf

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!

iamgergo avatar Mar 10 '22 09:03 iamgergo