Skip to content

FEATURE: Localization fallbacks (server-side)#2

Open
ShashankFC wants to merge 1 commit into
localization-system-prefrom
localization-system-post
Open

FEATURE: Localization fallbacks (server-side)#2
ShashankFC wants to merge 1 commit into
localization-system-prefrom
localization-system-post

Conversation

@ShashankFC

@ShashankFC ShashankFC commented Feb 4, 2026

Copy link
Copy Markdown

Test 9

Summary by CodeRabbit

Release Notes

  • Refactor

    • Restructured internationalization fallback system with optimized on-demand locale loading for improved efficiency.
    • Enhanced locale fallback resolution to intelligently cascade through requested language, site default, and English.
    • Consolidated locale initialization logic for better maintainability.
  • Chore

    • Removed deprecated pluralization backend integration from environment configurations.

✏️ Tip: You can customize this high-level summary in your review settings.


Replicated from ai-code-review-evaluation/discourse-coderabbit#9


EntelligenceAI PR Summary

This PR centralizes I18n locale fallback configuration into a dedicated initializer with a custom three-tier fallback strategy.

  • Removed config.i18n.fallbacks = true from production, profile, and cloud66 environment files
  • Created new config/initializers/i18n.rb with FallbackLocaleList class implementing user locale → site default → English fallback chain
  • Removed standalone config/initializers/pluralization.rb (functionality consolidated)
  • Added I18n.fallbacks.ensure_loaded! call in ApplicationController#set_locale method
  • Extracted reusable ensure_loaded! method in TranslateAccelerator for explicit locale loading API
  • Includes TODO for future language-specific fallback enhancements (e.g., Chinese variants)

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*
@entelligence-ai-pr-reviews

Copy link
Copy Markdown

Walkthrough

This PR refactors I18n locale fallback configuration by centralizing it into a dedicated initializer. Previously, fallback settings were scattered across multiple environment files (production, profile) and the pluralization initializer. The new approach introduces a custom FallbackLocaleList class that implements a three-tier fallback strategy (user locale → site default → English) with an ensure_loaded! method for preloading locales. The ApplicationController now explicitly calls this method after locale determination, while the TranslateAccelerator gains a public ensure_loaded! method for reusable locale loading. This consolidation improves maintainability and provides better control over translation fallback behavior.

Changes

File(s) Summary
config/cloud/cloud66/files/production.rb
config/environments/production.rb
config/environments/profile.rb
Removed I18n locale fallbacks configuration (config.i18n.fallbacks = true) from environment files, eliminating automatic fallback to default locale when translations are missing.
config/initializers/i18n.rb Created new I18n initializer with custom FallbackLocaleList class implementing three-tier fallback strategy (user locale → site default → English) with ensure_loaded! method for preloading fallback locales.
config/initializers/pluralization.rb Removed pluralization initializer that was configuring I18n's pluralization backend.
app/controllers/application_controller.rb Added call to I18n.fallbacks.ensure_loaded! at end of set_locale method to ensure fallback locales are properly loaded after locale determination.
lib/freedom_patches/translate_accelerator.rb Added public ensure_loaded! method to guarantee locale is loaded before use, initializing @loaded_locales and conditionally loading specified locale if not previously loaded.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    participant App as Application Code
    participant I18n as I18n System
    participant Fallbacks as I18n::Fallbacks
    participant SiteSetting as SiteSetting

    App->>SiteSetting: Get default_locale
    SiteSetting-->>App: Return locale value
    
    Note over App,Fallbacks: New: Ensure fallbacks are loaded
    App->>I18n: Access fallbacks
    I18n-->>App: Return Fallbacks instance
    App->>Fallbacks: ensure_loaded!
    activate Fallbacks
    Fallbacks->>Fallbacks: Load fallback configurations
    deactivate Fallbacks
    Fallbacks-->>App: Fallbacks ready
    
    Note over App: Continue with locale setup
Loading

🔗 Cross-Repository Impact Analysis

Enable automatic detection of breaking changes across your dependent repositories. → Set up now

Learn more about Cross-Repository Analysis

What It Does

  • Automatically identifies repositories that depend on this code
  • Analyzes potential breaking changes across your entire codebase
  • Provides risk assessment before merging to prevent cross-repo issues

How to Enable

  1. Visit Settings → Code Management
  2. Configure repository dependencies
  3. Future PRs will automatically include cross-repo impact analysis!

Benefits

  • 🛡️ Prevent breaking changes across repositories
  • 🔍 Catch integration issues before they reach production
  • 📊 Better visibility into your multi-repo architecture

▶️AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

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.

2 participants