FIX: Do not override existing translations.
This commit is contained in:
parent
eb7417ea0c
commit
556cd1e3f8
|
@ -70,7 +70,7 @@ module I18n
|
|||
if options[:overrides] && existing_translations
|
||||
if options[:count]
|
||||
|
||||
existing_translations =
|
||||
remapped_translations =
|
||||
if existing_translations.is_a?(Hash)
|
||||
Hash[existing_translations.map { |k, v| ["#{key}.#{k}", v] }]
|
||||
elsif existing_translations.is_a?(String)
|
||||
|
@ -79,7 +79,7 @@ module I18n
|
|||
|
||||
result = {}
|
||||
|
||||
existing_translations.merge(options[:overrides]).each do |k, v|
|
||||
remapped_translations.merge(options[:overrides]).each do |k, v|
|
||||
result[k.split('.').last.to_sym] = v if k != key && k.start_with?(key.to_s)
|
||||
end
|
||||
return result if result.size > 0
|
||||
|
|
|
@ -111,6 +111,13 @@ describe I18n::Backend::DiscourseI18n do
|
|||
expect(I18n.translate('wat', count: 123)).to eq('goodbye 123')
|
||||
end
|
||||
|
||||
it 'ignores interpolation named count if it is not applicable' do
|
||||
TranslationOverride.upsert!('en', 'test', 'goodbye')
|
||||
I18n.backend.store_translations(:en, test: 'foo')
|
||||
I18n.backend.store_translations(:en, wat: 'bar')
|
||||
expect(I18n.translate('wat', count: 1)).to eq('bar')
|
||||
end
|
||||
|
||||
it 'supports one and other' do
|
||||
TranslationOverride.upsert!('en', 'items.one', 'one fish')
|
||||
TranslationOverride.upsert!('en', 'items.other', '%{count} fishies')
|
||||
|
|
Loading…
Reference in New Issue