mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: Missing translation when translation override contained a %{key}
(#16625)
This happened only for languages other than "en" and when `I18n.t` was called without any interpolation keys. The lib still tried to interpolate keys because it interpreted the `overrides` option as interpolation key.
This commit is contained in:
@ -221,6 +221,19 @@ describe "translate accelerator" do
|
||||
override_translation('en', 'fish', 'fake fish')
|
||||
expect(Fish.model_name.human).to eq('Fish')
|
||||
end
|
||||
|
||||
it "works when the override contains an interpolation key" do
|
||||
expect(I18n.t("foo_with_variable")).to eq("Foo in :en with %{variable}")
|
||||
I18n.with_locale(:de) { expect(I18n.t("foo_with_variable")).to eq("Foo in :de with %{variable}") }
|
||||
|
||||
override_translation("en", "foo_with_variable", "Override in :en with %{variable}")
|
||||
expect(I18n.t("foo_with_variable")).to eq("Override in :en with %{variable}")
|
||||
I18n.with_locale(:de) { expect(I18n.t("foo_with_variable")).to eq("Foo in :de with %{variable}") }
|
||||
|
||||
override_translation("de", "foo_with_variable", "Override in :de with %{variable}")
|
||||
expect(I18n.t("foo_with_variable")).to eq("Override in :en with %{variable}")
|
||||
I18n.with_locale(:de) { expect(I18n.t("foo_with_variable")).to eq("Override in :de with %{variable}") }
|
||||
end
|
||||
end
|
||||
|
||||
context "translation precedence" do
|
||||
|
Reference in New Issue
Block a user