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
Very open to other ways of solving this problem.
This is not an existing feature, it would need to be built, can be done in a plugin.
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.
If user language selection is enabled I see no downside to having this as a default, built in thing at signup time.
The tricky thing though is that if you can not read English you are in a bit of a bind to even get to that page or select the language.
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.
Thanks for all the great responses.
Would it be easier to implement a language toggle (e.g. using images of flags) that would would stay on the top of every page like some websites have?
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.
How about using the
Accept-Language HTTP header when
allow_user_locale is enabled?
If someone visits the site and isn’t logged in yet we could use the first language from the HTTP header that is also available in Discourse.
How prevalent is that header?
I’d say it’s quite common and will work for 99% of all users. Most browsers send it unless the user explicitly changes or deactivates it.
What does it look like on my system?
- Internet Explorer:
- Chrome on Android:
Of course users should always be able to override the server detected language.
I support this, out of the box.
- If user locales are enabled
- If we have a mapping (keep in mind region locales make this annoying - de-AT vs de)
Automatically select locale for anonymous and logged on user, unless explicitly set in user prefs.
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.
I think this is what @sam is saying.
@simon I’d really love your feedback and would love to collaborate with you on this idea.
I’ve made a plugin for this. https://github.com/scossar/accept-language
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.
Amazing! Thanks @Simon_Cossar!
edit: seems to work flawlessly! Well done
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?
It works with Arabic for me. What browser and operating system are you trying it on?
Can you try it here http://tests.testeleven.com/ and see if that is working for you? (Ignore the content on the site - it’s just set-up for testing)
Unfortunately that site’s interface was also not displaying in Arabic for
me, the login buttons etc were displayed in English.
I am using Chrome Version 46.0.2490.86 (64-bit) on a Macbook Air with the
latest system updates (10.11.1)