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

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

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*
@ShashankFC

Copy link
Copy Markdown
Author

@cubic-dev-ai review this pull request

@cubic-dev-ai

cubic-dev-ai Bot commented Feb 13, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this pull request

@ShashankFC I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="config/initializers/i18n.rb">

<violation number="1" location="config/initializers/i18n.rb:9">
P2: Inconsistent and potentially fragile inclusion pattern. Line 5 references the class directly (`I18n::Backend::Simple`), but this line goes through the instance (`I18n.backend.class`). If the backend is ever wrapped (e.g., `I18n::Backend::Chain`), this would include `Fallbacks` into the wrong class. Consider using the class directly for consistency and robustness.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


# Include fallbacks module
require 'i18n/backend/fallbacks'
I18n.backend.class.send(:include, I18n::Backend::Fallbacks)

@cubic-dev-ai cubic-dev-ai Bot Feb 13, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Inconsistent and potentially fragile inclusion pattern. Line 5 references the class directly (I18n::Backend::Simple), but this line goes through the instance (I18n.backend.class). If the backend is ever wrapped (e.g., I18n::Backend::Chain), this would include Fallbacks into the wrong class. Consider using the class directly for consistency and robustness.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/initializers/i18n.rb, line 9:

<comment>Inconsistent and potentially fragile inclusion pattern. Line 5 references the class directly (`I18n::Backend::Simple`), but this line goes through the instance (`I18n.backend.class`). If the backend is ever wrapped (e.g., `I18n::Backend::Chain`), this would include `Fallbacks` into the wrong class. Consider using the class directly for consistency and robustness.</comment>

<file context>
@@ -0,0 +1,24 @@
+
+# Include fallbacks module
+require 'i18n/backend/fallbacks'
+I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
+
+# Configure custom fallback order
</file context>
Fix with Cubic

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