mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
FIX: Use correct locale when translating without cache
follow-up to 6d8eb9c1
This commit is contained in:
parent
4d1204b5e8
commit
a77d8bee68
@ -120,7 +120,7 @@ module I18n
|
||||
|
||||
val = @cache.getset(k) do
|
||||
begin
|
||||
translate_no_cache(key, raise: true).freeze
|
||||
translate_no_cache(key, locale: locale, raise: true).freeze
|
||||
rescue I18n::MissingTranslationData
|
||||
MissingTranslation
|
||||
end
|
||||
|
@ -33,6 +33,19 @@ describe "translate accelerator" do
|
||||
expect(I18n.t('i_am_an_unknown_key99')).to eq("translation missing: en_US.i_am_an_unknown_key99")
|
||||
end
|
||||
|
||||
it "returns the correct language" do
|
||||
expect(I18n.t('foo', locale: :en)).to eq('Foo in :en')
|
||||
expect(I18n.t('foo', locale: :de)).to eq('Foo in :de')
|
||||
|
||||
I18n.with_locale(:en) do
|
||||
expect(I18n.t('foo')).to eq('Foo in :en')
|
||||
end
|
||||
|
||||
I18n.with_locale(:de) do
|
||||
expect(I18n.t('foo')).to eq('Foo in :de')
|
||||
end
|
||||
end
|
||||
|
||||
it "overrides for both string and symbol keys" do
|
||||
key = 'user.email.not_allowed'
|
||||
text_overriden = 'foobar'
|
||||
|
@ -1,4 +1,4 @@
|
||||
en:
|
||||
foo: 'Foo in :de'
|
||||
bar: 'Bar in :de'
|
||||
de:
|
||||
foo: "Foo in :de"
|
||||
bar: "Bar in :de"
|
||||
wat: "Hello %{count}"
|
||||
|
@ -1,7 +1,7 @@
|
||||
en:
|
||||
got: "winter"
|
||||
foo: 'Foo in :en'
|
||||
bar: 'Bar in :en'
|
||||
foo: "Foo in :en"
|
||||
bar: "Bar in :en"
|
||||
wat: "Hello %{count}"
|
||||
world: "Hello %{world}"
|
||||
items:
|
||||
|
Loading…
Reference in New Issue
Block a user