The discussion revolves around implementing a feature to change the forum locale via a URL query parameter or an image of a flag in the header/footer. Dorian_McFarland initially asked if it’s possible to change the locale using a URL query parameter (e.g., ?locale=ja-JP) to help non-English speakers.
@mpalmer suggested that users can change their locale in their profile settings, but Dorian_McFarland clarified that they want a more visible option, like a flag image, to switch the UI language.
@pfaffman noted that changing the user locale is a PUT request, which requires more than just a URL, and might be possible with JavaScript in a theme. However, this would only be available to registered users.
It was concluded that the “locale from the browser for anonymous users” option might be the best solution for now, as changing the locale at a browser session level is not feasible. Dorian_McFarland thanked the users for their input.
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.
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.
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.
@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?
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.
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.