fix: IncomingRequest setLocale not falling back to generic language code#9884
Closed
markconnellypro wants to merge 3 commits intocodeigniter4:developfrom
Closed
fix: IncomingRequest setLocale not falling back to generic language code#9884markconnellypro wants to merge 3 commits intocodeigniter4:developfrom
markconnellypro wants to merge 3 commits intocodeigniter4:developfrom
Conversation
…t supportedLocale if country included
Enhanced locale validation to check for language-only locales before falling back to the default.
michalsn
reviewed
Jan 16, 2026
Member
michalsn
left a comment
There was a problem hiding this comment.
Looks good. Please add a changelog entry, under the "Bugs" section, here: https://github.com/codeigniter4/CodeIgniter4/blob/develop/user_guide_src/source/changelogs/v4.6.5.rst.
Please follow the convention used in previous files.
paulbalandan
approved these changes
Jan 17, 2026
Contributor
Author
|
I'm going to close this. I think this fix is going to have unintended consequences. |
Member
|
Thanks for the follow-up and for pointing out the potential side effects. After rechecking the user guide, I see that the current behavior is consistent with the docs, though it may not be immediately obvious. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The documentation currently states that:
This appears to be built in when Content Negotiation is used, but not when the setLocale function is called in IncomingRequest. This pull request changes this function so that it also tries the generic language code before setting the default locale as the locale. This avoids situations where, for example, "fr" is a supportedLocale, but, when "fr-FR" is passed to setLocale, it ignores this and picks a different default locale because "fr-FR" is not an exact match to "fr".
Checklist: