diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-31 13:39:41 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-08-31 21:13:02 +0200 |
commit | abe198723d76cea1b7f151a15789d26a3d22ad4d (patch) | |
tree | 82cb60da4a5528bf1166e8e2091a921c8ccb5d7f /spec/lib/gitlab/i18n/translation_entry_spec.rb | |
parent | 2c4f9b7a73cf5de875b2c77880c040e845960a9a (diff) | |
download | gitlab-ce-abe198723d76cea1b7f151a15789d26a3d22ad4d.tar.gz |
Take `nplurals` into account when validating translations.
Diffstat (limited to 'spec/lib/gitlab/i18n/translation_entry_spec.rb')
-rw-r--r-- | spec/lib/gitlab/i18n/translation_entry_spec.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/spec/lib/gitlab/i18n/translation_entry_spec.rb b/spec/lib/gitlab/i18n/translation_entry_spec.rb index e48ba28be0e..d2d3ec03c6d 100644 --- a/spec/lib/gitlab/i18n/translation_entry_spec.rb +++ b/spec/lib/gitlab/i18n/translation_entry_spec.rb @@ -4,7 +4,7 @@ describe Gitlab::I18n::TranslationEntry do describe '#singular_translation' do it 'returns the normal `msgstr` for translations without plural' do data = { msgid: 'Hello world', msgstr: 'Bonjour monde' } - entry = described_class.new(data) + entry = described_class.new(data, 2) expect(entry.singular_translation).to eq('Bonjour monde') end @@ -16,7 +16,7 @@ describe Gitlab::I18n::TranslationEntry do 'msgstr[0]' => 'Bonjour monde', 'msgstr[1]' => 'Bonjour mondes' } - entry = described_class.new(data) + entry = described_class.new(data, 2) expect(entry.singular_translation).to eq('Bonjour monde') end @@ -25,7 +25,7 @@ describe Gitlab::I18n::TranslationEntry do describe '#all_translations' do it 'returns all translations for singular translations' do data = { msgid: 'Hello world', msgstr: 'Bonjour monde' } - entry = described_class.new(data) + entry = described_class.new(data, 2) expect(entry.all_translations).to eq(['Bonjour monde']) end @@ -37,7 +37,7 @@ describe Gitlab::I18n::TranslationEntry do 'msgstr[0]' => 'Bonjour monde', 'msgstr[1]' => 'Bonjour mondes' } - entry = described_class.new(data) + entry = described_class.new(data, 2) expect(entry.all_translations).to eq(['Bonjour monde', 'Bonjour mondes']) end @@ -50,7 +50,7 @@ describe Gitlab::I18n::TranslationEntry do msgid_plural: 'Hello worlds', 'msgstr[0]' => 'Bonjour monde' } - entry = described_class.new(data) + entry = described_class.new(data, 1) expect(entry.plural_translations).to eq(['Bonjour monde']) end @@ -63,21 +63,21 @@ describe Gitlab::I18n::TranslationEntry do 'msgstr[1]' => 'Bonjour mondes', 'msgstr[2]' => 'Bonjour tous les mondes' } - entry = described_class.new(data) + entry = described_class.new(data, 3) expect(entry.plural_translations).to eq(['Bonjour mondes', 'Bonjour tous les mondes']) end end - describe '#has_singular?' do + describe '#has_singular_translation?' do it 'has a singular when the translation is not pluralized' do data = { msgid: 'hello world', msgstr: 'hello' } - entry = described_class.new(data) + entry = described_class.new(data, 2) - expect(entry).to have_singular + expect(entry).to have_singular_translation end it 'has a singular when plural and singular are separately defined' do @@ -87,9 +87,9 @@ describe Gitlab::I18n::TranslationEntry do "msgstr[0]" => 'hello world', "msgstr[1]" => 'hello worlds' } - entry = described_class.new(data) + entry = described_class.new(data, 2) - expect(entry).to have_singular + expect(entry).to have_singular_translation end it 'does not have a separate singular if the plural string only has one translation' do @@ -98,34 +98,34 @@ describe Gitlab::I18n::TranslationEntry do msgid_plural: 'hello worlds', "msgstr[0]" => 'hello worlds' } - entry = described_class.new(data) + entry = described_class.new(data, 1) - expect(entry).not_to have_singular + expect(entry).not_to have_singular_translation end end - describe '#msgid_contains_newlines'do + describe '#msgid_contains_newlines' do it 'is true when the msgid is an array' do data = { msgid: %w(hello world) } - entry = described_class.new(data) + entry = described_class.new(data, 2) expect(entry.msgid_contains_newlines?).to be_truthy end end - describe '#plural_id_contains_newlines'do + describe '#plural_id_contains_newlines' do it 'is true when the msgid is an array' do - data = { plural_id: %w(hello world) } - entry = described_class.new(data) + data = { msgid_plural: %w(hello world) } + entry = described_class.new(data, 2) expect(entry.plural_id_contains_newlines?).to be_truthy end end - describe '#translations_contain_newlines'do + describe '#translations_contain_newlines' do it 'is true when the msgid is an array' do data = { msgstr: %w(hello world) } - entry = described_class.new(data) + entry = described_class.new(data, 2) expect(entry.translations_contain_newlines?).to be_truthy end |