Skip to content

fix: setLocaleFromURL handle fallback locals and regex of BCP-47 Script/Region 🌋#733

Open
darcywong00 wants to merge 7 commits into
stagingfrom
fix/fallback
Open

fix: setLocaleFromURL handle fallback locals and regex of BCP-47 Script/Region 🌋#733
darcywong00 wants to merge 7 commits into
stagingfrom
fix/fallback

Conversation

@darcywong00
Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 commented May 11, 2026

Found while integrating Keyman for Android which reports Spanish locale as es-ES

Had to make the following changes to setLocaleFromURL():

  • check with fallback locales

  • Also update BCP-47 regex to capitalize Script and Region

This way, the following link shows in Spanish (which uses es.php files)
http://keyman.com.localhost/es-ES/keyboards/?embed=android&embed_version=19.0

invalid locale like
http://keyman.com.localhost/rv-tS/keyboards/?embed=android&embed_version=19.0

get a page not found.

I couldn't invalidate the locale because that broke _test pages like /_test/go (would treat _test as an invalid locale)

Test-bot: skip

@darcywong00 darcywong00 added this to the A19S29 milestone May 11, 2026
@darcywong00 darcywong00 requested a review from mcdurdin May 11, 2026 23:25
@keymanapp-test-bot
Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

* make regex case-insensitive
* assign fallback locale
@darcywong00 darcywong00 changed the base branch from epic/i18n-url-scheme to staging May 13, 2026 04:30
@darcywong00
Copy link
Copy Markdown
Contributor Author

force rebased onto staging

yeah, we can rebase to staging and close the web-i18n epic branch, so that we don't have confusion. When ready, we just make a back-port to master from staging PR

@mcdurdin
Copy link
Copy Markdown
Member

I think we want our URLs to redirect if a fallback is encountered, rather than accepting es-Fooo-BA as a substitute for es. And we don't want case insensitivity either; we don't want es, eS, Es, and ES all to return the same document, because URLs are case sensitive. So ... maybe we need to take this one back to the drawing board -- happy to discuss further.

Comment thread _includes/locale/Locale.php Outdated
* make case-sensitive
* fix capitalization of Script and Region
@darcywong00 darcywong00 changed the title fix: setLocaleFromURL (case-insensitive and handling fallback locales) 🌋 fix: setLocaleFromURL handle fallback locals and regex of BCP-47 Script/Region 🌋 May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants