diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-30 10:53:23 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-31 22:13:02 +0300 |
commit | 2c4f9b7a73cf5de875b2c77880c040e845960a9a (patch) | |
tree | 8e4bdd898c7ca19d2eded2ca1fd27bdb2be873c0 /lib | |
parent | f35a5d0d9919810b14d95808f099a3c652fb17b9 (diff) |
Check for newlines in different methods on TranslationEntry
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/i18n/po_linter.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/i18n/translation_entry.rb | 12 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/gitlab/i18n/po_linter.rb b/lib/gitlab/i18n/po_linter.rb index 0dc96ac7b9b..f5ffc6669e4 100644 --- a/lib/gitlab/i18n/po_linter.rb +++ b/lib/gitlab/i18n/po_linter.rb @@ -71,11 +71,15 @@ module Gitlab end def validate_newlines(errors, entry) - if entry.msgid.is_a?(Array) + if entry.msgid_contains_newlines? errors << "is defined over multiple lines, this breaks some tooling." end - if entry.all_translations.any? { |translation| translation.is_a?(Array) } + if entry.plural_id_contains_newlines? + errors << "plural is defined over multiple lines, this breaks some tooling." + end + + if entry.translations_contain_newlines? errors << "has translations defined over multiple lines, this breaks some tooling." end end diff --git a/lib/gitlab/i18n/translation_entry.rb b/lib/gitlab/i18n/translation_entry.rb index 98095177994..4fe8f569f9c 100644 --- a/lib/gitlab/i18n/translation_entry.rb +++ b/lib/gitlab/i18n/translation_entry.rb @@ -47,6 +47,18 @@ module Gitlab !plural? || all_translations.size > 1 end + def msgid_contains_newlines? + msgid.is_a?(Array) + end + + def plural_id_contains_newlines? + plural_id.is_a?(Array) + end + + def translations_contain_newlines? + all_translations.any? { |translation| translation.is_a?(Array) } + end + private def plural_translation_keys |