Skip to content

Conversation

@akshayutture-augment
Copy link

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Test 9


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


Note

Introduce I18n fallback support with custom order and ensure fallback locales are preloaded; consolidate pluralization init and remove env fallback flags.

  • I18n Fallbacks
    • Add config/initializers/i18n.rb to include pluralization and fallbacks, define FallbackLocaleList with order [locale, SiteSetting.default_locale, :en], and set I18n.fallbacks.
    • In ApplicationController#set_locale, call I18n.fallbacks.ensure_loaded! after setting I18n.locale.
    • Extend I18n translate accelerator with ensure_loaded!(locale) to lazy-load locales.
  • Config Cleanup
    • Remove config.i18n.fallbacks = true from production.rb, profile.rb, and Cloud66 production.rb.
    • Move pluralization setup from config/initializers/pluralization.rb into the new i18n.rb (delete old file).

Written by Cursor Bugbot for commit ecfa17b. Configure here.

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*
@akshayutture-augment
Copy link
Author

cursor review

# user locale, site locale, english
# TODO - this can be extended to be per-language for a better user experience
# (e.g. fallback zh_TW to zh_CN / vice versa)
[locale, SiteSetting.default_locale.to_sym, :en].uniq.compact
Copy link

Choose a reason for hiding this comment

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

Bug: Inconsistent Locale Types Break I18n

The FallbackLocaleList#[] method returns an array mixing string and symbol locale types. The locale parameter is returned as-is while SiteSetting.default_locale is converted to a symbol with .to_sym. This type inconsistency causes I18n.ensure_loaded! to store mixed types in @loaded_locales, breaking the .include? checks in translate_accelerator.rb and potentially causing locales to be loaded multiple times or not at all.

Fix in Cursor Fix in Web

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.

3 participants