Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2019-08-14 12:46:09 +0300
committerMaƂgorzata Ksionek <mksionek@gitlab.com>2019-09-10 14:22:21 +0300
commit8472fa0807ad04f076df42b4ea4f8a145685dc80 (patch)
tree042740d7936e58338dfc074aee957b0025aa7153 /lib/gitlab/i18n
parenteb2afea2abaa61978fae312a5a9b71293ab0e84a (diff)
Build correct variables for testing translations
This makes sure we build the correct variables for testing translations. When translating, we could be specifying the variables in different forms for each id: - In the singular we could be using a `%{hash}` interpolation - In the plural we could be using a `%d` interpolation This changes the tests to accommodate for that: We now use the variables used in the relevant translation id as the source for the variables we mix in in specs.
Diffstat (limited to 'lib/gitlab/i18n')
-rw-r--r--lib/gitlab/i18n/po_linter.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab/i18n/po_linter.rb b/lib/gitlab/i18n/po_linter.rb
index 3e9a035010f..aec3b1a3755 100644
--- a/lib/gitlab/i18n/po_linter.rb
+++ b/lib/gitlab/i18n/po_linter.rb
@@ -170,13 +170,18 @@ module Gitlab
end
def translate_plural(entry)
- used_variables = entry.plural_id.scan(VARIABLE_REGEX)
- variables = fill_in_variables(used_variables)
+ used_plural_variables = entry.plural_id.scan(VARIABLE_REGEX)
+ plural_variables = fill_in_variables(used_plural_variables)
+
+ used_singular_variables = entry.msgid.scan(VARIABLE_REGEX)
+ singular_variables = fill_in_variables(used_singular_variables)
numbers_covering_all_plurals.map do |number|
translation = FastGettext::Translation.n_(entry.msgid, entry.plural_id, number)
+ index = index_for_pluralization(number)
+ variables = index == 0 ? singular_variables : plural_variables
- translation % variables if used_variables.any?
+ translation % variables if variables.any?
end
end