diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-09-10 13:20:32 +0000 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-09-10 13:20:32 +0000 |
commit | 08b0613302ec813c0735e2c0447a3f7683d7ab87 (patch) | |
tree | feea2e5291303c4f93da86fcc26106b5a77ca915 | |
parent | 96a9a140e8382997687a7a10afc616a8fb8281ed (diff) | |
parent | 18a4afc50e098b3544fa0fc604177a99b7ad7983 (diff) | |
download | gitlab-ce-08b0613302ec813c0735e2c0447a3f7683d7ab87.tar.gz |
Merge branch 'reprazent/gitlab-ce-bvl-find-correct-variables-for-testing-translations' into 'master'
Build correct variables for testing translations
Closes #48110
See merge request gitlab-org/gitlab-ce!32871
-rw-r--r-- | lib/gitlab/i18n/po_linter.rb | 8 | ||||
-rw-r--r-- | spec/fixtures/valid.po | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/gitlab/i18n/po_linter.rb b/lib/gitlab/i18n/po_linter.rb index 3e9a035010f..c0687cd9b79 100644 --- a/lib/gitlab/i18n/po_linter.rb +++ b/lib/gitlab/i18n/po_linter.rb @@ -170,13 +170,13 @@ module Gitlab end def translate_plural(entry) - used_variables = entry.plural_id.scan(VARIABLE_REGEX) - variables = fill_in_variables(used_variables) - numbers_covering_all_plurals.map do |number| translation = FastGettext::Translation.n_(entry.msgid, entry.plural_id, number) + index = index_for_pluralization(number) + used_variables = index == 0 ? entry.msgid.scan(VARIABLE_REGEX) : entry.plural_id.scan(VARIABLE_REGEX) + variables = fill_in_variables(used_variables) - translation % variables if used_variables.any? + translation % variables if variables.any? end end diff --git a/spec/fixtures/valid.po b/spec/fixtures/valid.po index 155b6cbb95d..28826f05595 100644 --- a/spec/fixtures/valid.po +++ b/spec/fixtures/valid.po @@ -1128,3 +1128,8 @@ msgid "parent" msgid_plural "parents" msgstr[0] "padre" msgstr[1] "padres" + +msgid "CycleAnalytics|%{stageName}" +msgid_plural "CycleAnalytics|%d stages selected" +msgstr[0] "%{stageName}" +msgstr[1] "%d stages selected" |