FIX: Translation should return overrides first before attempting to fallback.
https://meta.discourse.org/t/errors-after-migrating-to-a-new-version-1-9-0-beta3/65709/14?u=tgxworld
This commit is contained in:
parent
f529cb1674
commit
b605d5d61b
|
@ -74,9 +74,8 @@ module I18n
|
|||
existing_translations = super(locale, key, scope, options)
|
||||
overrides = options.dig(:overrides, locale)
|
||||
|
||||
if overrides && existing_translations
|
||||
if options[:count]
|
||||
|
||||
if overrides && !scope&.include?(:models)
|
||||
if existing_translations && options[:count]
|
||||
remapped_translations =
|
||||
if existing_translations.is_a?(Hash)
|
||||
Hash[existing_translations.map { |k, v| ["#{key}.#{k}", v] }]
|
||||
|
|
|
@ -163,6 +163,19 @@ describe I18n::Backend::DiscourseI18n do
|
|||
.to eq('snow is the new queen')
|
||||
end
|
||||
|
||||
it "returns override if it exists before falling back" do
|
||||
I18n.backend.store_translations(:en, got: 'winter')
|
||||
|
||||
expect(I18n.translate('got', default: '')).to eq('winter')
|
||||
expect(I18n.with_locale(:ru) { I18n.translate('got', default: '') }).to eq('winter')
|
||||
|
||||
TranslationOverride.upsert!('ru', 'got', "summer")
|
||||
I18n.backend.store_translations(:en, got: 'winter')
|
||||
|
||||
expect(I18n.translate('got', default: '')).to eq('winter')
|
||||
expect(I18n.with_locale(:ru) { I18n.translate('got', default: '') }).to eq('summer')
|
||||
end
|
||||
|
||||
it 'supports ActiveModel::Naming#human' do
|
||||
Fish = Class.new(ActiveRecord::Base)
|
||||
|
||||
|
|
Loading…
Reference in New Issue