FEATURE: Localization fallbacks (server-side)#9
Conversation
The FallbackLocaleList object tells I18n::Backend::Fallbacks what order the languages should be attempted in. Because of the translate_accelerator patch, the SiteSetting.default_locale is *not* guaranteed to be fully loaded after the server starts, so a call to ensure_loaded! is added after the locale is set for the current user. The declarations of config.i18n.fallbacks = true in the environment files were actually garbage, because the I18n.default_locale was SiteSetting.default_locale, so there was nothing to fall back to. *derp*
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecfa17b5a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def [](locale) | ||
| # user locale, site locale, english | ||
| # TODO - this can be extended to be per-language for a better user experience | ||
| # (e.g. fallback zh_TW to zh_CN / vice versa) | ||
| [locale, SiteSetting.default_locale.to_sym, :en].uniq.compact |
There was a problem hiding this comment.
Preserve parent-locale fallbacks
The custom fallback list only tries the exact locale, the site default, and :en. That drops the standard parent-locale fallback chain (e.g., pt_BR → pt) provided by I18n::Locale::Fallbacks, so any missing pt_BR keys that exist in pt will now skip directly to the site default/English instead of the base language. This is a regression for regional locales that depend on shared base translations; consider merging parent locales into the list or delegating to I18n::Locale::Fallbacks before appending the site default.
Useful? React with 👍 / 👎.
Test 9
Replicated from ai-code-review-evaluation/discourse-cursor#9