Changing forum locale via URL param

multi-lingual

(Dorian Mc Farland) #1

Hi,
We’re trying to implement a flag in the header that would allow users from particular country to easily change the interface. I’m wondering if it’s possible to change the forum locale via a URL query parameter e.g. ?locale=ja-JP or similar.

I have seen the “set locale from accept language header” option, but this could behave unexpectedly for our established users, so I would rather have something obvious and visual to help non-english speakers.

thanks
Dorian


(Matt Palmer) #2

Isn’t going into the user’s profile and changing their locale sufficiently “obvious and visual”? I don’t think hand-editing URLs to add query params is either of those.


(Jay Pfaffman) #3

You could warn the established users if the change. If think that if someone’s browser is configured for a particular language they’d speak the language well enough to change it in their settings.


(Dorian Mc Farland) #4

@mpalmer thanks for getting back to me. I’m trying to work out if we can link to our forum and have it immediately display in a particular language. When I was talking about a flag in the header, I literally meant an image of a flag (e.g. a japanese flag) in the header or footer of the page that when clicked switches the UI to Japanese.

Probably better if I rephrase the question:
is it possible to switch the interface locale via URL query param, either for logged in or non-logged in users?

Dorian


(Jay Pfaffman) #5

OH! I get it. I’ve seen that on lots of sites–click the German flag for German, and so on. It still seems like the ‘get the local from the browser’ solution is a better (more modern) one. Changing the user local is a PUT, so it’ll take more than just a URL. I think it should be possible with some javascript in a theme, though.


(Dorian Mc Farland) #6

So to answer the question, if we’re talking about a PUT it sounds like it’s only possible to change the locale as a property of the user, rather than at a browser session level, and as such would only be available to registered users. The “locale from the browser for anonymous users” looks like it could be our best shot for the time being.

Thanks for the input.


(Christoph) #7

Using that setting entails quite some problems, especially if you are using a customized discobot welcome message. Unless you have the time and resources to change and maintain the welcome message in all available locales, discobot will send the wrong message to new users with a non-default locale. Unfortunately, there is currently no way of limiting the bot to use only certain locales.

So I’d like to explore this topic’s idea of setting user locale via the URL a bit further. My use case is that I would like to forward a specific URL (e.g. fr.myforum.com) to a specific local version of my forum. Now, I understand that

So what about this:

Can someone confirm that this is possible and provide some hints what needs to be done?

So to provide some concrete specs: I would like a theme component that sets the user’s locale based on a url parameter. Ideally, that parameter could be added to any valid forum-url but I would also be happy if there is one specific url for each locale that will trigger the locale-change if called.