Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
50be5faa1496
Commit
1de135bc
authored
Apr 19, 2017
by
Ruben Davila
Browse files
Fix Rubocop complains plus some small refactor
parent
ca3af652cbbf
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/controllers/application_controller.rb
View file @
50be5faa
...
...
@@ -269,6 +269,7 @@ def u2f_app_id
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
app/views/profiles/show.html.haml
View file @
50be5faa
...
...
@@ -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"
...
...
config/initializers/fast_gettext.rb
View file @
50be5faa
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'
db/migrate/20170413035209_add_preferred_language_to_users.rb
View file @
50be5faa
...
...
@@ -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
lib/gitlab/i18n.rb
View file @
50be5faa
module
Gitlab
module
I18n
AVAILABLE_LANGUAGES
=
[
[
'English'
,
'en'
],
[
'Spanish'
,
'es'
],
[
'Deutsch'
,
'de'
]
]
AVAILABLE_LANGUAGES
=
{
'en'
=>
'English'
,
'es'
=>
'Spanish'
,
'de'
=>
'Deutsch'
}.
freeze
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment