Variable default interface language for new users

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.

11 Likes