Alterar idioma para usuário não registrado

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.

Observe que agora você também pode permitir que os convidados definam seu idioma usando o “Seletor de idioma para convidados” em Multilingual Plugin 🌐 .

Menu ou rodapé

ou

Você já investigou problemas de cache com isso? O problema afetaria apenas sites que estão usando um CDN.

Sim, analisei bastante o cache. Acredito que ainda não acertei 100%, mas acho que é possível acertar.

Sim, ou se o visitante quiser usar um locale diferente do do seu navegador. Por exemplo, se estiverem usando um computador de uma biblioteca, escola ou outro computador compartilhado, ou se a própria pessoa for multilíngue.

A configuração definir locale a partir do cabeçalho Accept-Language ainda funciona por padrão com o seletor de locale ativado. Se o usuário não tiver clicado explicitamente em outro locale no seletor, ele usará o locale do navegador dele por meio dessa configuração (se possível).

Posso usar apenas o seletor de idioma sem o plugin completo? Talvez haja uma possibilidade além deste plugin?