Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
48261a07
Commit
48261a07
authored
May 03, 2021
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "i18n: Show translation levels for each language in the UI"
This reverts commit
7aa06e08
.
parent
4d9aabd2
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
103 deletions
+37
-103
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+3
-15
app/models/user.rb
app/models/user.rb
+1
-1
changelogs/unreleased/trans-levels-master-patch-26507.yml
changelogs/unreleased/trans-levels-master-patch-26507.yml
+0
-5
doc/development/i18n/merging_translations.md
doc/development/i18n/merging_translations.md
+0
-7
lib/gitlab/i18n.rb
lib/gitlab/i18n.rb
+15
-41
locale/gitlab.pot
locale/gitlab.pot
+0
-3
spec/features/profiles/user_edit_preferences_spec.rb
spec/features/profiles/user_edit_preferences_spec.rb
+13
-1
spec/helpers/preferences_helper_spec.rb
spec/helpers/preferences_helper_spec.rb
+0
-17
spec/lib/gitlab/i18n_spec.rb
spec/lib/gitlab/i18n_spec.rb
+5
-13
No files found.
app/helpers/preferences_helper.rb
View file @
48261a07
...
@@ -76,7 +76,7 @@ module PreferencesHelper
...
@@ -76,7 +76,7 @@ module PreferencesHelper
def
language_choices
def
language_choices
options_for_select
(
options_for_select
(
selectable_locales_with_translation_level
.
sort
,
Gitlab
::
I18n
.
selectable_locales
.
map
(
&
:reverse
)
.
sort
,
current_user
.
preferred_language
current_user
.
preferred_language
)
)
end
end
...
@@ -107,18 +107,6 @@ module PreferencesHelper
...
@@ -107,18 +107,6 @@ module PreferencesHelper
def
default_first_day_of_week
def
default_first_day_of_week
first_day_of_week_choices
.
rassoc
(
Gitlab
::
CurrentSettings
.
first_day_of_week
).
first
first_day_of_week_choices
.
rassoc
(
Gitlab
::
CurrentSettings
.
first_day_of_week
).
first
end
end
def
selectable_locales_with_translation_level
Gitlab
::
I18n
.
selectable_locales
.
map
do
|
code
,
language
|
[
s_
(
"i18n|%{language} (%{percent_translated}%% translated)"
)
%
{
language:
language
,
percent_translated:
Gitlab
::
I18n
.
percentage_translated_for
(
code
)
},
code
]
end
end
end
end
PreferencesHelper
.
prepend_if_ee
(
'EE::PreferencesHelper'
)
PreferencesHelper
.
prepend_if_ee
(
'EE::PreferencesHelper'
)
app/models/user.rb
View file @
48261a07
...
@@ -431,7 +431,7 @@ class User < ApplicationRecord
...
@@ -431,7 +431,7 @@ class User < ApplicationRecord
def
preferred_language
def
preferred_language
read_attribute
(
'preferred_language'
)
||
read_attribute
(
'preferred_language'
)
||
I18n
.
default_locale
.
to_s
.
presence_in
(
Gitlab
::
I18n
.
available_locale
s
)
||
I18n
.
default_locale
.
to_s
.
presence_in
(
Gitlab
::
I18n
::
AVAILABLE_LANGUAGES
.
key
s
)
||
'en'
'en'
end
end
...
...
changelogs/unreleased/trans-levels-master-patch-26507.yml
deleted
100644 → 0
View file @
4d9aabd2
---
title
:
Add the translation level for each language in the user profile language selector
merge_request
:
59420
author
:
type
:
changed
doc/development/i18n/merging_translations.md
View file @
48261a07
...
@@ -78,10 +78,3 @@ recreate it with the following steps:
...
@@ -78,10 +78,3 @@ recreate it with the following steps:
1.
Select the
`gitlab-org/gitlab`
repository.
1.
Select the
`gitlab-org/gitlab`
repository.
1.
In
`Select Branches for Translation`
, select
`master`
.
1.
In
`Select Branches for Translation`
, select
`master`
.
1.
Ensure the
`Service Branch Name`
is
`master-i18n`
.
1.
Ensure the
`Service Branch Name`
is
`master-i18n`
.
## Manually update the translation levels
There's no automated way to pull the translation levels from CrowdIn, to display
this information in the language selection dropdown. Therefore, the translation
levels are hard-coded in the
`TRANSLATION_LEVELS`
constant in
[
`i18n.rb`
](
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/i18n.rb
)
,
and must be regularly updated.
lib/gitlab/i18n.rb
View file @
48261a07
...
@@ -4,6 +4,20 @@ module Gitlab
...
@@ -4,6 +4,20 @@ module Gitlab
module
I18n
module
I18n
extend
self
extend
self
# Languages with less then 2% of available translations will not
# be available in the UI.
# https://gitlab.com/gitlab-org/gitlab/-/issues/221012
NOT_AVAILABLE_IN_UI
=
%w[
fil_PH
pl_PL
nl_NL
id_ID
cs_CZ
bg
eo
gl_ES
]
.
freeze
AVAILABLE_LANGUAGES
=
{
AVAILABLE_LANGUAGES
=
{
'bg'
=>
'Bulgarian - български'
,
'bg'
=>
'Bulgarian - български'
,
'cs_CZ'
=>
'Czech - čeština'
,
'cs_CZ'
=>
'Czech - čeština'
,
...
@@ -28,49 +42,9 @@ module Gitlab
...
@@ -28,49 +42,9 @@ module Gitlab
'zh_HK'
=>
'Chinese, Traditional (Hong Kong) - 繁體中文 (香港)'
,
'zh_HK'
=>
'Chinese, Traditional (Hong Kong) - 繁體中文 (香港)'
,
'zh_TW'
=>
'Chinese, Traditional (Taiwan) - 繁體中文 (台灣)'
'zh_TW'
=>
'Chinese, Traditional (Taiwan) - 繁體中文 (台灣)'
}.
freeze
}.
freeze
private_constant
:AVAILABLE_LANGUAGES
# Languages with less then MINIMUM_TRANSLATION_LEVEL% of available translations will not
# be available in the UI.
# https://gitlab.com/gitlab-org/gitlab/-/issues/221012
MINIMUM_TRANSLATION_LEVEL
=
2
# Currently monthly updated manually by ~group::import PM.
# https://gitlab.com/gitlab-org/gitlab/-/issues/18923
TRANSLATION_LEVELS
=
{
'bg'
=>
1
,
'cs_CZ'
=>
1
,
'de'
=>
20
,
'en'
=>
100
,
'eo'
=>
1
,
'es'
=>
44
,
'fil_PH'
=>
1
,
'fr'
=>
14
,
'gl_ES'
=>
1
,
'id_ID'
=>
0
,
'it'
=>
3
,
'ja'
=>
49
,
'ko'
=>
15
,
'nl_NL'
=>
1
,
'pl_PL'
=>
1
,
'pt_BR'
=>
23
,
'ru'
=>
34
,
'tr_TR'
=>
18
,
'uk'
=>
46
,
'zh_CN'
=>
78
,
'zh_HK'
=>
3
,
'zh_TW'
=>
4
}.
freeze
private_constant
:TRANSLATION_LEVELS
def
selectable_locales
def
selectable_locales
@selectable_locales
||=
AVAILABLE_LANGUAGES
.
reject
do
|
code
,
_name
|
AVAILABLE_LANGUAGES
.
reject
{
|
key
,
_value
|
NOT_AVAILABLE_IN_UI
.
include?
key
}
percentage_translated_for
(
code
)
<
MINIMUM_TRANSLATION_LEVEL
end
end
def
percentage_translated_for
(
code
)
TRANSLATION_LEVELS
.
fetch
(
code
,
0
)
end
end
def
available_locales
def
available_locales
...
...
locale/gitlab.pot
View file @
48261a07
...
@@ -37939,9 +37939,6 @@ msgstr ""
...
@@ -37939,9 +37939,6 @@ msgstr ""
msgid "https://your-bitbucket-server"
msgid "https://your-bitbucket-server"
msgstr ""
msgstr ""
msgid "i18n|%{language} (%{percent_translated}%% translated)"
msgstr ""
msgid "image diff"
msgid "image diff"
msgstr ""
msgstr ""
...
...
spec/features/profiles/user_edit_preferences_spec.rb
View file @
48261a07
# frozen_string_literal: true
# frozen_string_literal: true
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
'User edit preferences profile'
,
:js
do
RSpec
.
describe
'User edit preferences profile'
,
:js
do
...
@@ -64,4 +63,17 @@ RSpec.describe 'User edit preferences profile', :js do
...
@@ -64,4 +63,17 @@ RSpec.describe 'User edit preferences profile', :js do
expect
(
page
).
to
have_content
(
'Failed to save preferences.'
)
expect
(
page
).
to
have_content
(
'Failed to save preferences.'
)
end
end
end
end
describe
'User language'
do
let
(
:user
)
{
create
(
:user
,
preferred_language: :es
)
}
it
'shows the user preferred language by default'
do
expect
(
page
).
to
have_select
(
'user[preferred_language]'
,
selected:
'Spanish - español'
,
options:
Gitlab
::
I18n
.
selectable_locales
.
values
,
visible: :all
)
end
end
end
end
spec/helpers/preferences_helper_spec.rb
View file @
48261a07
...
@@ -121,23 +121,6 @@ RSpec.describe PreferencesHelper do
...
@@ -121,23 +121,6 @@ RSpec.describe PreferencesHelper do
end
end
end
end
describe
'#language_choices'
do
it
'lists all the selectable language options with their translation percent'
do
stub_const
(
'Gitlab::I18n::TRANSLATION_LEVELS'
,
'en'
=>
100
,
'es'
=>
65
)
stub_user
(
preferred_language: :en
)
expect
(
helper
.
language_choices
).
to
eq
([
'<option selected="selected" value="en">English (100% translated)</option>'
,
'<option value="es">Spanish - español (65% translated)</option>'
].
join
(
"
\n
"
))
end
end
def
stub_user
(
messages
=
{})
def
stub_user
(
messages
=
{})
if
messages
.
empty?
if
messages
.
empty?
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
nil
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
nil
)
...
...
spec/lib/gitlab/i18n_spec.rb
View file @
48261a07
...
@@ -3,21 +3,13 @@
...
@@ -3,21 +3,13 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Gitlab
::
I18n
do
RSpec
.
describe
Gitlab
::
I18n
do
let
(
:user
)
{
create
(
:user
,
preferred_language:
:es
)
}
let
(
:user
)
{
create
(
:user
,
preferred_language:
'es'
)
}
describe
'.selectable_locales'
do
describe
'.selectable_locales'
do
it
'does not return languages with low translation levels'
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/-/issues/329723'
do
it
'does not return languages that should not be available in the UI'
do
stub_const
(
Gitlab
::
I18n
::
NOT_AVAILABLE_IN_UI
.
each
do
|
language
|
'Gitlab::I18n::TRANSLATION_LEVELS'
,
expect
(
described_class
.
selectable_locales
).
not_to
include
(
language
)
'pt_BR'
=>
0
,
end
'en'
=>
100
,
'es'
=>
65
)
expect
(
described_class
.
selectable_locales
).
to
eq
({
'en'
=>
'English'
,
'es'
=>
'Spanish - español'
})
end
end
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