diff --git a/lib/freedom_patches/translate_accelerator.rb b/lib/freedom_patches/translate_accelerator.rb index c5e8abf3a..8b734f9c8 100644 --- a/lib/freedom_patches/translate_accelerator.rb +++ b/lib/freedom_patches/translate_accelerator.rb @@ -90,7 +90,6 @@ module I18n key = args.shift locale = options[:locale] || config.locale - @cache ||= LruRedux::ThreadSafeCache.new(LRU_CACHE_SIZE) k = "#{key}#{locale}#{config.backend.object_id}" @@ -122,7 +121,7 @@ module I18n end end - by_site[locale] + by_site[locale].with_indifferent_access end def client_overrides_json(locale) @@ -138,8 +137,7 @@ module I18n load_locale(locale) unless @loaded_locales.include?(locale) if @overrides_enabled - by_locale = overrides_by_locale(locale) - if by_locale + if by_locale = overrides_by_locale(locale) if options.present? options[:overrides] = by_locale @@ -152,9 +150,9 @@ module I18n return result end end - end end + translate_no_override(key, options) end diff --git a/spec/components/freedom_patches/translate_accelerator_spec.rb b/spec/components/freedom_patches/translate_accelerator_spec.rb new file mode 100644 index 000000000..6fef757ee --- /dev/null +++ b/spec/components/freedom_patches/translate_accelerator_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +describe "translate accelerator" do + + it "overrides for both string and symbol keys" do + key = "user.email.not_allowed" + text_overriden = "foobar" + + expect(I18n.t(key)).to be_present + + TranslationOverride.upsert!("en", key, text_overriden) + + expect(I18n.t(key)).to eq(text_overriden) + expect(I18n.t(key.to_sym)).to eq(text_overriden) + end + +end