summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-08-24 19:32:53 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-08-31 21:13:00 +0200
commit49b38194775a6f0043a0f7f2d01932fcdea69810 (patch)
tree3445d241c353973162222ec6ae160404adceeeb1
parent1da594d39b4b5d6d905ab9a8325d694b3b0fbec7 (diff)
downloadgitlab-ce-49b38194775a6f0043a0f7f2d01932fcdea69810.tar.gz
Only perform `join_message` in `validate_variable_usage`
-rw-r--r--lib/gitlab/po_linter.rb17
-rw-r--r--spec/lib/gitlab/po_linter_spec.rb1
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/gitlab/po_linter.rb b/lib/gitlab/po_linter.rb
index 44abea640c3..162ba4058e6 100644
--- a/lib/gitlab/po_linter.rb
+++ b/lib/gitlab/po_linter.rb
@@ -86,15 +86,7 @@ module Gitlab
validate_unnamed_variables(errors, required_variables)
validate_translation(errors, message_id, required_variables)
-
- message_translation = join_message(message_translation)
-
- # We don't need to validate when the message is empty.
- # Translations could fallback to the default, or we could be validating a
- # language that does not have plurals.
- unless message_translation.empty?
- validate_variable_usage(errors, message_translation, required_variables)
- end
+ validate_variable_usage(errors, message_translation, required_variables)
end
def validate_translation(errors, message_id, used_variables)
@@ -150,6 +142,13 @@ module Gitlab
end
def validate_variable_usage(errors, translation, required_variables)
+ translation = join_message(translation)
+
+ # We don't need to validate when the message is empty.
+ # Translations could fallback to the default, or we could be validating a
+ # language that does not have plurals.
+ return if translation.empty?
+
found_variables = translation.scan(VARIABLE_REGEX)
missing_variables = required_variables - found_variables
diff --git a/spec/lib/gitlab/po_linter_spec.rb b/spec/lib/gitlab/po_linter_spec.rb
index 74a3d8b95f8..649d5d8127d 100644
--- a/spec/lib/gitlab/po_linter_spec.rb
+++ b/spec/lib/gitlab/po_linter_spec.rb
@@ -226,7 +226,6 @@ describe Gitlab::PoLinter do
expect(errors).to include('Failure translating to en with []: broken')
end
-
it "adds an error when trying to translate with incorrect variables when using unnamed variables" do
errors = []