BigW Consortium Gitlab

Commit 1de135bc by Ruben Davila

Fix Rubocop complains plus some small refactor

parent 302e855f
...@@ -269,6 +269,7 @@ class ApplicationController < ActionController::Base ...@@ -269,6 +269,7 @@ class ApplicationController < ActionController::Base
def set_locale def set_locale
requested_locale = current_user&.preferred_language || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale requested_locale = current_user&.preferred_language || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale
locale = FastGettext.set_locale(requested_locale) locale = FastGettext.set_locale(requested_locale)
I18n.locale = locale I18n.locale = locale
end end
end end
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
%span.help-block This email will be displayed on your public profile. %span.help-block This email will be displayed on your public profile.
.form-group .form-group
= f.label :preferred_language, class: "label-light" = f.label :preferred_language, class: "label-light"
= f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |lang| [_(lang[0]), lang[1]] }, = f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |value, label| [_(label), value] },
{}, class: "select2" {}, class: "select2"
.form-group .form-group
= f.label :skype, class: "label-light" = f.label :skype, class: "label-light"
......
FastGettext.add_text_domain 'gitlab', path: 'locale', type: :po FastGettext.add_text_domain 'gitlab', path: 'locale', type: :po
FastGettext.default_available_locales = ['en', 'es','de'] FastGettext.default_available_locales = Gitlab::I18n::AVAILABLE_LANGUAGES.keys
FastGettext.default_text_domain = 'gitlab' FastGettext.default_text_domain = 'gitlab'
...@@ -8,7 +8,11 @@ class AddPreferredLanguageToUsers < ActiveRecord::Migration ...@@ -8,7 +8,11 @@ class AddPreferredLanguageToUsers < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def change def up
add_column_with_default :users, :preferred_language, :string, default: 'en' add_column_with_default :users, :preferred_language, :string, default: 'en'
end end
def down
remove_column :users, :preferred_language
end
end end
module Gitlab module Gitlab
module I18n module I18n
AVAILABLE_LANGUAGES = [ AVAILABLE_LANGUAGES = {
['English', 'en'], 'en' => 'English',
['Spanish', 'es'], 'es' => 'Spanish',
['Deutsch', 'de'] 'de' => 'Deutsch'
] }.freeze
end end
end end
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