Changing forum locale via URL param

(Dorian Mc Farland) #1

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.


(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?


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