mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Do not override existing translations.
This commit is contained in:
@@ -70,7 +70,7 @@ module I18n
|
|||||||
if options[:overrides] && existing_translations
|
if options[:overrides] && existing_translations
|
||||||
if options[:count]
|
if options[:count]
|
||||||
|
|
||||||
existing_translations =
|
remapped_translations =
|
||||||
if existing_translations.is_a?(Hash)
|
if existing_translations.is_a?(Hash)
|
||||||
Hash[existing_translations.map { |k, v| ["#{key}.#{k}", v] }]
|
Hash[existing_translations.map { |k, v| ["#{key}.#{k}", v] }]
|
||||||
elsif existing_translations.is_a?(String)
|
elsif existing_translations.is_a?(String)
|
||||||
@@ -79,7 +79,7 @@ module I18n
|
|||||||
|
|
||||||
result = {}
|
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)
|
result[k.split('.').last.to_sym] = v if k != key && k.start_with?(key.to_s)
|
||||||
end
|
end
|
||||||
return result if result.size > 0
|
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')
|
expect(I18n.translate('wat', count: 123)).to eq('goodbye 123')
|
||||||
end
|
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
|
it 'supports one and other' do
|
||||||
TranslationOverride.upsert!('en', 'items.one', 'one fish')
|
TranslationOverride.upsert!('en', 'items.one', 'one fish')
|
||||||
TranslationOverride.upsert!('en', 'items.other', '%{count} fishies')
|
TranslationOverride.upsert!('en', 'items.other', '%{count} fishies')
|
||||||
|
|||||||
Reference in New Issue
Block a user