-
Notifications
You must be signed in to change notification settings - Fork 0
FEATURE: Localization fallbacks (server-side) #2
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
base: localization-system-pre
Are you sure you want to change the base?
FEATURE: Localization fallbacks (server-side) #2
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*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Controller as ApplicationController
participant I18n as I18n Module
participant Fallbacks as FallbackLocaleList
participant Accelerator as TranslateAccelerator
participant Backend as I18n::Backend
Controller->>Controller: set_locale()
Controller->>I18n: Set locale (user or site default)
Controller->>Fallbacks: ensure_loaded!()
Fallbacks->>Fallbacks: self[I18n.locale]
Note over Fallbacks: Returns [user_locale, site_default, :en]
loop For each locale in fallback chain
Fallbacks->>I18n: ensure_loaded!(locale)
I18n->>Accelerator: load_locale(locale)
Note over Accelerator: Check if already loaded
alt Not yet loaded
Accelerator->>Backend: load_translations(locale files)
Accelerator->>Accelerator: Add to @loaded_locales
end
end
Note over Controller,Backend: Later during request...
Controller->>I18n: translate(key)
I18n->>Accelerator: Check cache
alt Cache miss
I18n->>Backend: Lookup with fallbacks
Note over Backend: Tries user locale → site default → :en
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 files reviewed, no comments
Test 9
Replicated from ai-code-review-evaluation/discourse-greptile#9