"Set locale from param" and content localisation issue

AI-generated summary

The discussion revolves around a bug in the Set locale from param feature, where anonymous users’ locale set via the tl URL parameter (e.g., ?tl=fi) is not consistently applied across the site. While the UI and headers display correctly in the specified language, clicking into a thread reverts to the browser’s Accept-Language header (e.g., English). MiikkaLaitila highlights this inconsistency, noting that the locale should persist throughout navigation. nat agrees, acknowledging the expected behavior and sharing a recording to illustrate the issue. nat then confirms a fix has been implemented and deployed on meta, with a pull request (https://github.com/discourse/discourse/pull/35942) and a working example provided.

We’ve been rather happy with the content localisation, but found an issue regarding
Set locale from param setting.

It should allow setting an anonymous user’s locale via the ‘tl’ URL param, e.g. ?tl=es. Currently if we put e.g. ?tl=fi to forum URL, it correctly shows the UI and forum headers in Finnish for anonymous user. Yet if I click any thread open, it shows them incorrectly according browser’s Accept language header (English in this case).

If I understood correctly, priority should be ?lang= in the URL, then the locale cookie, then Accept-Language? Still at least in our case it seems that using ?tl only changes UI language but not shown translations.

As for the context what we’re trying to achieve:

  • Guide users to Swedish forum version (tl=sv) from our .se site, and to Finnish version (tl=fi) from our .fi site and so on.
  • For anonymous users browsing globally, it would be nice to have the browser locale header setting as default if we or user haven’t pre-selected the language.

Any thoughts?

2 Likes

Hmmmm I see.

I think that is also the ideal experience I would expect. For some reason, I had expected my original implementation to follow that.

I’ve added a recording here for others to understand the issue and will be working on it. Will also move this over to Contribute > Bug since it’s not intended behaviour :slight_smile:

Recording

4 Likes

We have a fix here -

https://github.com/discourse/discourse/pull/35942


The fix is deployed on meta and here’s an example of anon view in a spanish browser and search term leading to a tl=es meta url -

3 Likes

This topic was automatically closed after 5 days. New replies are no longer allowed.