DEV: Add specs for handling InvalidPluralizationData exception
follow-up to 6d44be51
This commit is contained in:
parent
bbab60fa9b
commit
13e54bca3d
|
@ -94,4 +94,23 @@ describe I18n::Backend::DiscourseI18n do
|
|||
expect(backend.exists?(:ru, :bogus)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pluralize' do
|
||||
it 'uses fallback locales when a pluralization key is missing' do
|
||||
SiteSetting.default_locale = 'ru'
|
||||
|
||||
backend.store_translations(:ru, items: { one: '%{count} Russian item', other: '%{count} Russian items' })
|
||||
|
||||
expect(backend.translate(:ru, :items, count: 1)).to eq('1 Russian item')
|
||||
expect(backend.translate(:ru, :items, count: 2)).to eq('2 items')
|
||||
expect(backend.translate(:ru, :items, count: 5)).to eq('5 Russian items')
|
||||
|
||||
backend.store_translations(:ru, items: { one: '%{count} Russian item', few: '%{count} Russian items are a few', other: '%{count} Russian items' })
|
||||
expect(backend.translate(:ru, :items, count: 2)).to eq('2 Russian items are a few')
|
||||
|
||||
backend.store_translations(:en, airplanes: { one: '%{count} airplane' })
|
||||
expect(backend.translate(:ru, :airplanes, count: 1)).to eq('1 airplane')
|
||||
expect { backend.translate(:ru, :airplanes, count: 2) }.to raise_error(I18n::InvalidPluralizationData)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue