diff options
author | Ruben Davila <rdavila84@gmail.com> | 2017-04-13 01:03:47 -0500 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2017-04-13 01:03:47 -0500 |
commit | 73d0730d09b5f9a9b68f158cc72ad30c7a2b35d0 (patch) | |
tree | 3443759bd564dca586716c46d6dd8c74594432e7 | |
parent | 020e12a6ae99e9b9dfaa3cfbd640ecdf31d7424d (diff) | |
download | gitlab-ce-73d0730d09b5f9a9b68f158cc72ad30c7a2b35d0.tar.gz |
Set locale through controller filter
-rw-r--r-- | app/controllers/application_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/profiles_controller.rb | 1 | ||||
-rw-r--r-- | app/views/profiles/show.html.haml | 3 | ||||
-rw-r--r-- | lib/gitlab/i18n.rb | 6 | ||||
-rw-r--r-- | locale/de/gitlab.edit.po | 11 | ||||
-rw-r--r-- | locale/de/gitlab.po | 9 | ||||
-rw-r--r-- | locale/en/gitlab.edit.po | 11 | ||||
-rw-r--r-- | locale/en/gitlab.po | 9 | ||||
-rw-r--r-- | locale/es/gitlab.edit.po | 17 | ||||
-rw-r--r-- | locale/es/gitlab.po | 15 | ||||
-rw-r--r-- | locale/gitlab.pot | 13 |
11 files changed, 86 insertions, 15 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e77094fe2a8..5a3bd4040cc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -265,4 +265,10 @@ class ApplicationController < ActionController::Base 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 diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 57e23cea00e..0f01bf7e706 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -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 diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index dc71a04cbf0..d8ef64ceb72 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -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" diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb index 8c578aa0b46..85e527afd71 100644 --- a/lib/gitlab/i18n.rb +++ b/lib/gitlab/i18n.rb @@ -1,9 +1,9 @@ module Gitlab module I18n AVAILABLE_LANGUAGES = [ - [_('English'), 'en'], - [_('Spanish'), 'es'], - [_('Deutsch'), 'de'] + ['English', 'en'], + ['Spanish', 'es'], + ['Deutsch', 'de'] ] end end diff --git a/locale/de/gitlab.edit.po b/locale/de/gitlab.edit.po index 70ac9a35be7..e4c8caef164 100644 --- a/locale/de/gitlab.edit.po +++ b/locale/de/gitlab.edit.po @@ -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 "" diff --git a/locale/de/gitlab.po b/locale/de/gitlab.po index 5eb4a86d528..7f32771b80f 100644 --- a/locale/de/gitlab.po +++ b/locale/de/gitlab.po @@ -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 "" diff --git a/locale/en/gitlab.edit.po b/locale/en/gitlab.edit.po index f9e8c3e6709..048f531de4b 100644 --- a/locale/en/gitlab.edit.po +++ b/locale/en/gitlab.edit.po @@ -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 "" diff --git a/locale/en/gitlab.po b/locale/en/gitlab.po index 5dcd2983f30..f93f438b424 100644 --- a/locale/en/gitlab.po +++ b/locale/en/gitlab.po @@ -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 "" diff --git a/locale/es/gitlab.edit.po b/locale/es/gitlab.edit.po index 38a2d10f6e8..b5b6c0a671f 100644 --- a/locale/es/gitlab.edit.po +++ b/locale/es/gitlab.edit.po @@ -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" diff --git a/locale/es/gitlab.po b/locale/es/gitlab.po index 893eb7e15a3..e2d03d88347 100644 --- a/locale/es/gitlab.po +++ b/locale/es/gitlab.po @@ -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" diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7c4f303a5d0..a90fc69d94b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -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 "" |