From 45f4ce379e8ef85a048b2a042ddedcd961add8d0 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 11 Jul 2017 13:16:48 +0900 Subject: [PATCH] Fix broken specs. --- lib/i18n/backend/discourse_i18n.rb | 4 +++- spec/components/discourse_i18n_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/i18n/backend/discourse_i18n.rb b/lib/i18n/backend/discourse_i18n.rb index 988bf87d5f6..f940bd8804d 100644 --- a/lib/i18n/backend/discourse_i18n.rb +++ b/lib/i18n/backend/discourse_i18n.rb @@ -72,9 +72,11 @@ module I18n # the original translations before applying our overrides. def lookup(locale, key, scope = [], options = {}) existing_translations = super(locale, key, scope, options) + return existing_translations if scope.is_a?(Array) && scope.include?(:models) + overrides = options.dig(:overrides, locale) - if overrides && !scope&.include?(:models) + if overrides if existing_translations && options[:count] remapped_translations = if existing_translations.is_a?(Hash) diff --git a/spec/components/discourse_i18n_spec.rb b/spec/components/discourse_i18n_spec.rb index 7db8d9a6cc9..70212a8b0b2 100644 --- a/spec/components/discourse_i18n_spec.rb +++ b/spec/components/discourse_i18n_spec.rb @@ -176,7 +176,7 @@ describe I18n::Backend::DiscourseI18n do expect(I18n.with_locale(:ru) { I18n.translate('got', default: '') }).to eq('summer') end - it 'supports ActiveModel::Naming#human' do + it 'does not affect ActiveModel::Naming#human' do Fish = Class.new(ActiveRecord::Base) TranslationOverride.upsert!('en', 'fish', "fake fish")