Fix Rubocop complains plus some small refactor
This commit is contained in:
parent
302e855f52
commit
1de135bc04
|
@ -269,6 +269,7 @@ class ApplicationController < ActionController::Base
|
|||
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
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
%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.map { |lang| [_(lang[0]), lang[1]] },
|
||||
= f.select :preferred_language, Gitlab::I18n::AVAILABLE_LANGUAGES.map { |value, label| [_(label), value] },
|
||||
{}, class: "select2"
|
||||
.form-group
|
||||
= f.label :skype, class: "label-light"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
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'
|
||||
|
|
|
@ -8,7 +8,11 @@ class AddPreferredLanguageToUsers < ActiveRecord::Migration
|
|||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
def up
|
||||
add_column_with_default :users, :preferred_language, :string, default: 'en'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :users, :preferred_language
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module Gitlab
|
||||
module I18n
|
||||
AVAILABLE_LANGUAGES = [
|
||||
['English', 'en'],
|
||||
['Spanish', 'es'],
|
||||
['Deutsch', 'de']
|
||||
]
|
||||
AVAILABLE_LANGUAGES = {
|
||||
'en' => 'English',
|
||||
'es' => 'Spanish',
|
||||
'de' => 'Deutsch'
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue