Commit 1de135bc authored by Ruben Davila's avatar Ruben Davila

Fix Rubocop complains plus some small refactor

parent 302e855f
......@@ -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"
......
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
module Gitlab
module I18n
AVAILABLE_LANGUAGES = [
['English', 'en'],
['Spanish', 'es'],
['Deutsch', 'de']
]
AVAILABLE_LANGUAGES = {
'en' => 'English',
'es' => 'Spanish',
'de' => 'Deutsch'
}.freeze
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