-
Notifications
You must be signed in to change notification settings - Fork 3
FEATURE: Localization fallbacks (server-side) #7
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?
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*
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
User description
PR #9
PR Type
Enhancement
Description
Implement server-side localization fallbacks with custom fallback order
Add
ensure_loaded!method to guarantee locale availabilityRemove redundant
config.i18n.fallbacksdeclarations from environment filesConsolidate I18n configuration into dedicated initializer
Diagram Walkthrough
File Walkthrough
application_controller.rb
Ensure fallback locales loaded on locale setapp/controllers/application_controller.rb
I18n.fallbacks.ensure_loaded!inset_localemethodcurrent user
i18n.rb
Create I18n configuration with fallback supportconfig/initializers/i18n.rb
FallbackLocaleListclass with custom fallback order: userlocale → site locale → English
ensure_loaded!method to preload all fallback localestranslate_accelerator.rb
Add ensure_loaded method for locale loadinglib/freedom_patches/translate_accelerator.rb
ensure_loaded!method to load a specific locale if not alreadyloaded
@loaded_localesarray and callsload_localeif neededpluralization.rb
Remove pluralization configurationconfig/initializers/pluralization.rb
production.rb
Remove redundant fallbacks configurationconfig/environments/production.rb
config.i18n.fallbacks = truedeclarationprofile.rb
Remove redundant fallbacks configurationconfig/environments/profile.rb
config.i18n.fallbacks = truedeclarationproduction.rb
Remove redundant fallbacks configurationconfig/cloud/cloud66/files/production.rb
config.i18n.fallbacks = truedeclaration