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

[11.x] Use correct pluralization rules in trans_choice for fallback strings #52343

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

stefanvdlugt
Copy link
Contributor

@stefanvdlugt stefanvdlugt commented Jul 31, 2024

The trans_choice function uses the pluralization rules of the preferred language. If the preferred language and the fallback language have different rules, and the key is not found in the preferred language, the fallback language is used but with the pluralization rules of the preferred language, causing unexpected results. See issue #52341 for an example.

This PR updates Translator::localeForChoice() so that it returns the fallback locale if the preferred language does not have a translation for the given key.

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@stefanvdlugt stefanvdlugt force-pushed the fix-trans-choice-fallback branch from d4e9f5a to 9735ca8 Compare July 31, 2024 14:55
@stefanvdlugt stefanvdlugt marked this pull request as ready for review July 31, 2024 15:50
@stefanvdlugt stefanvdlugt changed the title [11.x] localeForChoice returns fallback if key doesn't exist [11.x] Use correct pluralization rules in trans_choice for fallback strings Aug 1, 2024
@driesvints
Copy link
Member

Thanks! @stefanvdlugt best to add a thorough explanation to your PR instead of just linking to an issue (see the PR template when you submit PR's).

@taylorotwell taylorotwell merged commit c034a2c into laravel:11.x Aug 1, 2024
29 checks passed
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

Successfully merging this pull request may close these issues.

3 participants