Skip to content

Automated Test: localization-system-post #323

Closed

Conversation

admin-coderabbit
Copy link
Owner

@admin-coderabbit admin-coderabbit commented Feb 4, 2026

This pull request was automatically created by @coderabbitai/e2e-reviewer.

Batch created pull request.

Summary by CodeRabbit

  • Refactor
    • Improved internationalization (i18n) architecture by consolidating locale fallback and pluralization handling into a unified system with customizable fallback order.
    • Optimized locale initialization to ensure translation data loads at runtime when needed.

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*
@coderabbit-eval
Copy link

coderabbit-eval bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The pull request refactors I18n locale fallback and pluralization handling. Static environment configurations setting config.i18n.fallbacks are removed and replaced with a custom FallbackLocaleList class in the i18n initializer that dynamically determines fallback order using site settings. Pluralization backend setup is consolidated into the i18n initializer, and a runtime ensure_loaded! method is added to guarantee locale data availability.

Changes

Cohort / File(s) Summary
Environment Configuration Removals
config/environments/production.rb, config/environments/profile.rb, config/cloud/cloud66/files/production.rb
Removed static config.i18n.fallbacks = true configuration and related comments from all three environment files.
I18n Initialization Refactoring
config/initializers/i18n.rb, config/initializers/pluralization.rb
Moved I18n::Backend::Pluralization integration from pluralization.rb into i18n.rb. Introduced new FallbackLocaleList class that provides dynamic fallback order based on locale and SiteSetting.default_locale. Set I18n.fallbacks to instance of FallbackLocaleList and added I18n::Backend::Fallbacks support.
Runtime Locale Loading
lib/freedom_patches/translate_accelerator.rb, app/controllers/application_controller.rb
Added ensure_loaded!(locale) singleton method to I18n::Backend for explicit locale initialization. Controller's set_locale method now calls I18n.fallbacks.ensure_loaded! after determining locale to ensure fallback data is loaded at runtime.

Sequence Diagram(s)

sequenceDiagram
    participant Controller as Controller<br/>(set_locale)
    participant Fallbacks as I18n.fallbacks<br/>(FallbackLocaleList)
    participant Backend as I18n::Backend
    participant Setting as SiteSetting

    Controller->>Fallbacks: ensure_loaded!()
    Fallbacks->>Setting: get default_locale
    Fallbacks->>Backend: load_locale(locale)
    Fallbacks->>Backend: load_locale(default_locale)
    Fallbacks->>Backend: load_locale(:en)
    Backend-->>Fallbacks: loaded
    Fallbacks-->>Controller: ready
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 whiskers twitching with joy

Locales now load with care,
FallbackLists float through the air,
No config stuck in static place,
Runtime calls set the pace! 🌍✨

🚥 Pre-merge checks | ✅ 1 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'Automated Test: localization-system-post' is vague and does not meaningfully describe the actual changes. While it references 'localization-system', the substantial refactoring involves moving I18n fallback and pluralization configuration from environment files to initializers, plus adding a custom fallback locale strategy. Replace with a more specific title describing the core change, such as 'Refactor I18n fallbacks and pluralization initialization' or 'Move I18n configuration to custom initializers with runtime fallback loading'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch localization-system-post

Comment @coderabbit eval help to get the list of available commands and usage tips.

@coderabbit-eval coderabbit-eval bot closed this Feb 4, 2026
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant