Changing language for non registered user

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

2 Likes

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.

6 Likes

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.

3 Likes

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

5 Likes

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).

1 Like

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