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>2018-05-07 18:56:18 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-06-15 15:58:46 +0300
commit3b5ce6945dee059717855962271245bbb29f24e1 (patch)
treec499b124287fa38686556fa62d03d0825aaaf284 /spec/lib/gitlab/i18n
parentca065e493e7a62f22cb330659e75f8567fa6131f (diff)
Validate PO-variable usage in message ids
That way we can detect incorrect usage before the strings are added to Crowdin for translation
Diffstat (limited to 'spec/lib/gitlab/i18n')
-rw-r--r--spec/lib/gitlab/i18n/po_linter_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/i18n/po_linter_spec.rb b/spec/lib/gitlab/i18n/po_linter_spec.rb
index 9bbd51fe212..045916e6dc2 100644
--- a/spec/lib/gitlab/i18n/po_linter_spec.rb
+++ b/spec/lib/gitlab/i18n/po_linter_spec.rb
@@ -220,6 +220,10 @@ describe Gitlab::I18n::PoLinter do
end
describe '#validate_variables' do
+ before do
+ allow(linter).to receive(:validate_variables_in_message).and_call_original
+ end
+
it 'validates both singular and plural in a pluralized string when the entry has a singular' do
pluralized_entry = fake_translation(
id: 'Hello %{world}',
@@ -259,6 +263,24 @@ describe Gitlab::I18n::PoLinter do
linter.validate_variables([], entry)
end
+
+ it 'validates variable usage in message ids' do
+ entry = fake_translation(
+ id: 'Hello %{world}',
+ translation: 'Bonjour %{world}',
+ plural_id: 'Hello all %{world}',
+ plurals: ['Bonjour tous %{world}']
+ )
+
+ expect(linter).to receive(:validate_variables_in_message)
+ .with([], 'Hello %{world}', 'Hello %{world}')
+ .and_call_original
+ expect(linter).to receive(:validate_variables_in_message)
+ .with([], 'Hello all %{world}', 'Hello all %{world}')
+ .and_call_original
+
+ linter.validate_variables([], entry)
+ end
end
describe '#validate_variables_in_message' do