{{ message }}
Fix i18n locale detection for Telegram region codes (pt-br -> pt_BR)#1776
Open
mahisafa82 wants to merge 2 commits into
Open
Fix i18n locale detection for Telegram region codes (pt-br -> pt_BR)#1776mahisafa82 wants to merge 2 commits into
mahisafa82 wants to merge 2 commits into
Conversation
Resolve user locale by checking the Telegram language code as-is, then its Babel-normalized form, then the base language. This fixes lowercase regional codes such as pt-br failing to match available translations like pt_BR. Add tests covering region-code variants and fallback behavior, and update i18n documentation plus changelog notes.
✔️ Changelog found.Thank you for adding a description of the changes |
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.
Resolve user locale by checking the Telegram language code as-is, then its Babel-normalized form, then the base language. This fixes lowercase regional codes such as pt-br failing to match available translations like pt_BR. Add tests covering region-code variants and fallback behavior, and update i18n documentation plus changelog notes.
Description
This PR improves locale detection in SimpleI18nMiddleware by resolving the user locale in this order: Telegram language code as received, Babel-normalized locale, then base language. This fixes cases where Telegram returns lowercase regional codes such as pt-br and translations exist under pt_BR, which previously caused fallback to the default locale.
The change also adds test coverage for region-code variants and fallback behavior, updates the i18n documentation to explain this resolution flow, and includes a changelog note.
Fixes #1755
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: