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

Allow configuring available languages from helm chart #2230

Merged
merged 55 commits into from
Dec 14, 2024

Conversation

emma-sg
Copy link
Member

@emma-sg emma-sg commented Dec 10, 2024

Closes #2223

  • Adds localesAvailable to /api/settings endpoint, and uses that list if available, rather than the full list of translated locales, to determine which options to display to users
  • Uses the user's browser locales, filtered to the current language setting, for formatting numbers, dates, and durations
  • Adds & persists checkbox for "use same language for formatting dates and numbers" in user settings
  • Replaces uses of sl-format-bytes with localize.bytes(...), and sl-format-date with replacement btrix-format-date that properly handles fallback locales
  • Caches all number/duration/datetime formatters by a combined key consisting of app language, browser language, browser setting, and formatter options so that all formatters can be reused if needed (previously any formatter with non-default options would be recreated every render)
  • Splits out ordinal formatting from number formatter, as it didn't make much sense in some non-English locales
  • Adds a little demo of date/time/duration/number formatting so you can see what effect your language settings have
Screen.Recording.2024-12-12.at.7.09.32.PM.mov

@emma-sg emma-sg force-pushed the i18n-hardcode-locales branch 2 times, most recently from 1745c06 to 824748f Compare December 11, 2024 02:43
@emma-sg emma-sg marked this pull request as ready for review December 11, 2024 02:46
@emma-sg emma-sg requested review from ikreymer and SuaYoo December 11, 2024 02:46
@emma-sg emma-sg marked this pull request as draft December 11, 2024 22:14
emma-sg and others added 21 commits December 12, 2024 15:06
Signed-off-by: emma <hi@emma.cafe>
Signed-off-by: emma <hi@emma.cafe>
Signed-off-by: emma <hi@emma.cafe>
Signed-off-by: emma <hi@emma.cafe>
Signed-off-by: emma <hi@emma.cafe>
Signed-off-by: emma <hi@emma.cafe>
Signed-off-by: emma <hi@emma.cafe>
uses a ponyfilled `Intl.LocaleMatcher` to match against the available
languages, and ensures that the list of available languages is present
at first load by explicitly loading app settings before initializing
language.
@emma-sg emma-sg force-pushed the i18n-hardcode-locales branch from dd3b07c to f723ce2 Compare December 12, 2024 20:06
@emma-sg
Copy link
Member Author

emma-sg commented Dec 13, 2024

Documenting this in case it comes up again: for whatever reason we were getting CORS errors in Playwright trying to call API endpoints that were proxied, which caused the page to never complete loading. Adding changeOrigin: true to the createProxyMiddleware configs fixed this in 147dd13.

@emma-sg emma-sg merged commit b650762 into main Dec 14, 2024
4 checks passed
@emma-sg emma-sg deleted the i18n-hardcode-locales branch December 14, 2024 03:31
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.

[Feature]: Update preferred language list
2 participants