为未注册用户更改语言

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.

请注意,您现在还可以使用 Multilingual Plugin 🌐 中的“访客语言切换器”允许访客设置其语言环境。

菜单或页脚

你检查过与此相关的缓存问题吗?该问题仅会影响使用 CDN 的网站。

是的,我已经对缓存问题进行了相当多的研究。我认为我还没有完全解决它,但我相信这是可以实现的。

是的,或者如果访客希望使用与其浏览器不同的语言环境。例如,他们正在使用图书馆、学校或其他共享计算机,或者他们本人是多语言使用者。

“根据 Accept-Language 请求头设置语言环境”选项在启用语言切换器时仍按默认方式工作。如果用户未通过切换器显式选择其他语言环境,则该设置将默认使用其浏览器的语言环境(如果可行)。

我可以仅使用语言切换器而不使用完整插件吗?除了这个插件之外,还有其他的可能性吗?