This discussion revolves around implementing automatic interface language selection for new and anonymous users on multilingual Discourse forums. Initially, user Conor_O_Rourke requested a way to auto-set language via URL (e.g., /ar, /en) for non-technical users. While not a built-in feature, Sam and Simon proposed solutions including language selection at signup or via HTTP Accept-Language headers. Gerhard advocated for using browser headers, noting their widespread support. Simon_Cossar developed a plugin that sets locale for anonymous users based on headers, later merged into Discourse core with refinements by Sam. However, issues arose for invited users, as invite redemption bypassed locale detection (Schungx). Simon clarified that locale is set during public signup via I18n.locale, but not during invite redemption — a gap later addressed by David. Simon summarized setup: enable allow user locale and set locale from accept language header in Basic Setup. For existing users, language is set in profile preferences. The feature now works for public signups and anonymous users, but not for invite-based signups unless patched. Loginerror and JammyDodger discussed compatibility with the Translator plugin, noting that ‘Everyone’ group restrictions may not work for anonymous users — TL0 is recommended instead. The community largely supports integrating this into core, and the functionality is now available out-of-the-box with proper configuration.
New Discourse user here, but super impressed and excited about what a great product it is. I am developing a forum that will be multilingual (Arabic/English/German). Most users will be extremely limited in the other languages, basically I don’t want to expect a German/English speaker to be able to read Arabic script, and vice versa. I also don’t want to rely too much on their computer skills—want to make this as easy as possible.
Is there a way that I can provide a separate URL that would auto-set the interface language on first visit, so that registration can happen in their native language? Something like discourse.example.com/ar and discourse.example.com/en
Maybe it could be useful to add an input to the existing sign-up form that allows a user to select their default language at the time they sign up. That way, when they first log in they will see the forum in a language they understand. This could be made as a plugin. There could also be a banner that appears for non-logged-in users. It could be in all your forum’s languages and guide speakers of each language through the log-in process.
Another way to do it would be to provide a separate site to help users log in. There could be a link on the forum in each of the target languages saying something like ‘click here if you need help getting started.’ That would link to a sign-up form in the appropriate language. It looks like it takes two API requests - one to create the user and one to set their language preference.
That makes sense. I think it could be done as a plugin. Clicking on the flag would cause a new translation file to be downloaded and tell the application to start using it.
WAAAHOOO! I’m glad this is being discussed. Here’s my take.
Effectively, I have two forums running on one codebase. Right now, I have an english and farsi forum, and we’re making plans on adding more but are stuck on this language issue.
Ideally, we want browser detection. I’ve deployed this jQuery script to some success.
For my user story:
I want “guest/non-athunicated” users see the forum in their native language.
When a user creates an account, they select the interface language they want to use.
The logic is that if the site is visited by a non-logged-in user and the site allows user-locales, the locale is set from the request headers. If there is a logged-in user the locale is set from the user’s effective locale. If there is no logged-in user and user locales are disabled, the locale is set from the site default locale.
It uses the http_accept_language gem to deal with those.
The only problem I am finding with this is when login is required to view any site content, the ‘login required welcome message’ markdown content isn’t translated. The rest of the user interface is translated though.
The problem with the login message is that SiteText.text_for method caches it’s content.
It works until the user signs in. After that they are back using the site default locale until they set the locale they want in their user preferences. I’ll see if I can add the locale selector to the sign-up form.
I’ve added a locale selector to the sign-up form. It defaults to the locale from the users Accept-Language headers.
The activation email that is sent after the user signs up is sent in the site’s default language - not the user’s chosen language. Other than that, everything seems to be working as it should.
For some reason, I am having trouble getting this plugin to choose Arabic as a language. I’ve tried with German and French, and with those languages, the automatic switch works perfectly. But with Arabic, my actual target language, the auto-switch seems to fail, and it just shows English interface text. Any ideas?