Skip to content

FIX: Use resolved locale for localizations, instead of param+site default fallback#39395

Merged
nattsw merged 2 commits intomainfrom
fix-fallback-title
Apr 21, 2026
Merged

FIX: Use resolved locale for localizations, instead of param+site default fallback#39395
nattsw merged 2 commits intomainfrom
fix-fallback-title

Conversation

@nattsw
Copy link
Copy Markdown
Contributor

@nattsw nattsw commented Apr 21, 2026

Related issue:

Our TopicListResponder determined content locale using only the ?tl= URL param, falling back to SiteSetting.default_locale. This ignored the locale cookie set by the language switcher or persisted from a previous ?tl= visit. The fix is to simply use I18n.locale which is already resolved from all sources (?tl= param, cookie, Accept-Language header, site default).

This only affects initial page loads and browser refreshes. Ember internal navigation (format.json) is unaffected since it doesn't call localize_topic_list_content.

Scenarios affected and fixed (per related urls):

  1. Anonymous user switches to German via language switcher → German-origin topics show English titles on page load
  2. User arrives via ?tl=fi from Google → first page works, but subsequent navigations (without ?tl= in URL) fall back to English despite the locale cookie being set

def localize_topic_list_content(list)
return if list.topics.blank? || !SiteSetting.content_localization_enabled
crawl_locale = params[Discourse::LOCALE_PARAM].presence || SiteSetting.default_locale
crawl_locale = I18n.locale
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From PR description:

The fix is to simply use I18n.locale which is already resolved from all sources (?tl= param, cookie, Accept-Language header, site default).

@tgxworld
Copy link
Copy Markdown
Contributor

@nattsw test failures are legit though

Also enable set_locale_from_param in the crawler localization
test, since I18n.locale only picks up the ?tl= param when this
setting is active.
@nattsw nattsw merged commit a44f0d1 into main Apr 21, 2026
19 checks passed
@nattsw nattsw deleted the fix-fallback-title branch April 21, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants