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

trans_choice uses wrong pluralization rules for fallback #52341

Closed
stefanvdlugt opened this issue Jul 31, 2024 · 2 comments
Closed

trans_choice uses wrong pluralization rules for fallback #52341

stefanvdlugt opened this issue Jul 31, 2024 · 2 comments

Comments

@stefanvdlugt
Copy link
Contributor

stefanvdlugt commented Jul 31, 2024

Laravel Version

11.8.0

PHP Version

8.2.18

Database Driver & Version

MySQL 8.0.32 for Linux on x86_64

Description

The trans_choice translation function always uses the pluralization rules of the selected locale. If the provided key is not translated in this locale, it falls back to the fallback locale, but it still uses the pluralization rules of the preferred locale.

For example, Czech has 3 forms, while English has 2. If the translator must fall back to English, it should use the English pluralization rules.

Steps To Reproduce

app('translator')->setLocale('cs_CZ');
$fallback = app('translator')->getFallback();
app('translator')->addLines(['strings.apple' => ':count apple|:count apples'], $fallback);
trans_choice('strings.apple', 1); // 1 apple
trans_choice('strings.apple', 2); // 2 apples
trans_choice('strings.apple', 10); // 10 apple - WRONG
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@driesvints
Copy link
Member

Seems you sent in a PR so let's see how it goes 👍

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

No branches or pull requests

3 participants