Commit 73d0730d authored by Ruben Davila's avatar Ruben Davila
Browse files

Set locale through controller filter

parent 457c13a42d18
......@@ -265,4 +265,10 @@ def gitlab_project_import_enabled?
def u2f_app_id
request.base_url
end
def set_locale
requested_locale = current_user&.preferred_language || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale
locale = FastGettext.set_locale(requested_locale)
I18n.locale = locale
end
end
......@@ -3,6 +3,7 @@ class ProfilesController < Profiles::ApplicationController
before_action :user
before_action :authorize_change_username!, only: :update_username
before_action :set_locale, only: :show
skip_before_action :require_email, only: [:show, :update]
def show
......
......@@ -74,7 +74,8 @@
%span.help-block This email will be displayed on your public profile.
.form-group
= f.label :preferred_language, class: "label-light"
= f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES, {}, class: "select2"
= f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |lang| [_(lang[0]), lang[1]] },
{}, class: "select2"
.form-group
= f.label :skype, class: "label-light"
= f.text_field :skype, class: "form-control"
......
module Gitlab
module I18n
AVAILABLE_LANGUAGES = [
[_('English'), 'en'],
[_('Spanish'), 'es'],
[_('Deutsch'), 'de']
['English', 'en'],
['Spanish', 'es'],
['Deutsch', 'de']
]
end
end
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-12 22:36-0500\n"
"POT-Creation-Date: 2017-04-13 00:01-0500\n"
"PO-Revision-Date: 2017-04-12 22:37-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: German\n"
......@@ -17,3 +17,12 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"\n"
msgid "Deutsch"
msgstr ""
msgid "English"
msgstr ""
msgid "Spanish"
msgstr ""
......@@ -16,3 +16,12 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"\n"
msgid "Deutsch"
msgstr ""
msgid "English"
msgstr ""
msgid "Spanish"
msgstr ""
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-12 22:36-0500\n"
"POT-Creation-Date: 2017-04-13 00:01-0500\n"
"PO-Revision-Date: 2017-04-12 22:36-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: English\n"
......@@ -17,3 +17,12 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"\n"
msgid "Deutsch"
msgstr ""
msgid "English"
msgstr ""
msgid "Spanish"
msgstr ""
......@@ -16,3 +16,12 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"\n"
msgid "Deutsch"
msgstr ""
msgid "English"
msgstr ""
msgid "Spanish"
msgstr ""
......@@ -7,13 +7,22 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-12 22:36-0500\n"
"PO-Revision-Date: 2017-04-12 22:37-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2017-04-13 00:07-0500\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"\n"
"POT-Creation-Date: 2017-04-13 00:01-0500\n"
"Last-Translator: \n"
"X-Generator: Poedit 2.0.1\n"
msgid "Deutsch"
msgstr "Alemán"
msgid "English"
msgstr "Inglés"
msgid "Spanish"
msgstr "Español"
......@@ -7,12 +7,21 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2017-04-12 22:37-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2017-04-13 00:07-0500\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"\n"
"Last-Translator: \n"
"X-Generator: Poedit 2.0.1\n"
msgid "Deutsch"
msgstr "Alemán"
msgid "English"
msgstr "Inglés"
msgid "Spanish"
msgstr "Español"
......@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-12 22:36-0500\n"
"PO-Revision-Date: 2017-04-12 22:36-0500\n"
"POT-Creation-Date: 2017-04-13 00:01-0500\n"
"PO-Revision-Date: 2017-04-13 00:01-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
......@@ -17,3 +17,12 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
msgid "Deutsch"
msgstr ""
msgid "English"
msgstr ""
msgid "Spanish"
msgstr ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment