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

feat: Add Locale.php class to set current locale 📡 #520

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

darcywong00
Copy link
Contributor

@darcywong00 darcywong00 commented Dec 9, 2024

Continues #384

This starts a Locale.php class which will expand to handle pointing to the localized.po files.
For now, it allows the current locale to be set with a query parameter like lang=fr-FR (previously was locale)

And confirmed with test code on keyboards/index.php

      <li>Current locale is <?= Locale::currentLocale() ?></li>      

@darcywong00 darcywong00 added this to the A18S17 milestone Dec 9, 2024
@darcywong00 darcywong00 requested a review from mcdurdin December 9, 2024 04:08
Comment on lines 34 to 36
if(isset($_REQUEST['locale'])) {
\Keyman\Site\com\keyman\Locale::overrideCurrentLocale($_REQUEST['locale']);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but we do need to validate that it's an acceptable locale

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO on follow-on PR once I add some .po files and workout how it fallsback to en strings.

@mcdurdin
Copy link
Member

mcdurdin commented Dec 9, 2024

I haven't really considered how we set locale via url (keyman.com/en/foo vs keyman.com/foo?lang=en vs en.keyman.com/foo). (I like lang instead of locale but it's not critical). All of these options have pros and cons... bleagh :)

@darcywong00
Copy link
Contributor Author

I haven't really considered how we set locale via url (keyman.com/en/foo vs keyman.com/foo?lang=en vs en.keyman.com/foo). (I like lang instead of locale but it's not critical). All of these options have pros and cons... bleagh :)

I changed the query parameter from locale to lang

@darcywong00 darcywong00 merged commit e2f44a4 into feat/localize/keyboard-search Dec 11, 2024
2 checks passed
@darcywong00 darcywong00 deleted the feat/locale-session branch December 11, 2024 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants