Changing language for non registered user

AI-generated summary

The discussion revolves around adding a language switcher for non-registered users on a Discourse site in Switzerland, which requires support for multiple languages (French, German, Italian, and English).

olivier asked if there’s a plugin or code available to add a language dropdown menu in the header. simon suggested enabling the set locale from accept language header and allow user locale Site Settings, which can set the locale for non-logged-in users based on their web browser’s language preferences.

simon confirmed that this feature is solid and reliable. Alternatively, angus mentioned the “Guest locale switcher” in the Multilingual Plugin, which allows guests to set their locale. However, simon raised concerns about caching issues with this plugin, especially for sites using a CDN.

angus acknowledged these concerns and mentioned that the plugin does handle cases where guests want to use a locale different from their browser’s. Ed_Bobkov asked if it’s possible to use only the language switcher without the full plugin, but no direct answer was provided.

Hi,

Some of our customers want to be able to visit our discourse in their language (we are in Switzerland, we have to play with french, german, italian and english). Thse customers are not / don’t want to register. How could we add a way for them to change language of Discourse?
I could see a dropdown menu listing some languages in the header. Is there already a plugin, of some code I could use ?

Thanks

If your site is not using a CDN to deliver assets, you could try enabling the set locale from accept language header SIte Setting. When enabled, this setting will set the locale for non-logged-in users from the language preferences they have set on their web browser. For the setting to work, you also need to enable the allow user locale Site Setting.

Hi Simon,

We aren’t using a CDN, indeed :slight_smile: I didn’t saw that switch. Its an experimental feature.. is it still solid ?

Yes. As long as you are not using a CDN, it should reliably set the locale for anonymous users to their web browser’s locale. How well it works for your users will depend on whether or not they have configured their web browsers to use their preferred language. You could try enabling the setting and then asking users about how well it’s working for them.

Note that you can now also allow guests to set their locale using the “Guest locale switcher” in the Multilingual Plugin 🌐 .

Menu or footer

or

Have you looked into caching issues with this? The issue would only affect sites that are using a CDN.

Yes, I’ve looked at the caching a fair bit. I don’t think I’ve got it 100% right yet, but I do think it’s possible (to get it right).

Yes, or if the guest wants to use a locale different from their browser. For example they’re using a computer at a library, or school, or some other shared computer, or they themselves are multilingual.

The set locale from accept language header setting still works by default with the locale switcher enabled. If the user hasn’t explicitly clicked on another locale in the switcher, it will default to their browser locale via that setting (if possible).

Can I use only language switcher without full plugin? May by there is a possibility except this plugin?