diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-22 17:23:43 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-31 22:13:00 +0300 |
commit | 973c697960b9538222c5a83dfe643107313097cc (patch) | |
tree | e2a99fb0e90e80ebc104397ed5e39534caa83402 /lib | |
parent | c34cf3a95286e46a23abdd567aedf2e4a6c72d5e (diff) |
Add spec for languages without plurals
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/po_linter.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/po_linter.rb b/lib/gitlab/po_linter.rb index 54594949711..721a111e2a0 100644 --- a/lib/gitlab/po_linter.rb +++ b/lib/gitlab/po_linter.rb @@ -66,7 +66,11 @@ module Gitlab def validate_variables(errors, entry) if entry[:msgid_plural].present? validate_variables_in_message(errors, entry[:msgid], entry['msgstr[0]']) - validate_variables_in_message(errors, entry[:msgid_plural], entry['msgstr[1]']) + + # Validate all plurals + entry.keys.select { |key_name| key_name =~ /msgstr\[[1-9]\]/ }.each do |plural_key| + validate_variables_in_message(errors, entry[:msgid_plural], entry[plural_key]) + end else validate_variables_in_message(errors, entry[:msgid], entry[:msgstr]) end @@ -80,6 +84,10 @@ module Gitlab 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 |