A platform for community discussion. Free, open, simple.
FIX: Use default locale for footer of embedded topics (#17760)
Gerhard Schlagerf3b2ee8e1b73
diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rbindex 18e154e9779..1d5676e5d9e 100644--- a/app/models/topic_embed.rb+++ b/app/models/topic_embed.rb@@ -23,7 +23,9 @@ class TopicEmbed < ActiveRecord::Baseenddef self.imported_from_html(url)- "\n<hr>\n<small>#{I18n.t('embed.imported_from', link: "<a href='#{url}'>#{url}</a>")}</small>\n"+ I18n.with_locale(SiteSetting.default_locale) do+ "\n<hr>\n<small>#{I18n.t('embed.imported_from', link: "<a href='#{url}'>#{url}</a>")}</small>\n"+ endend# Import an article from a source (RSS/Atom/Other)diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rbindex a63c9eaef4d..a112a126ffc 100644--- a/spec/models/topic_embed_spec.rb+++ b/spec/models/topic_embed_spec.rb@@ -399,4 +399,18 @@ RSpec.describe TopicEmbed doendend+ describe ".imported_from_html" do+ after { I18n.reload! }++ it "uses the default site locale for the 'imported_from' footer" do+ TranslationOverride.upsert!("en", "embed.imported_from", "English translation of embed.imported_from with %{link}")+ TranslationOverride.upsert!("de", "embed.imported_from", "German translation of embed.imported_from with %{link}")++ I18n.locale = :en+ expected_html = TopicEmbed.imported_from_html("some_url")++ I18n.locale = :de+ expect(TopicEmbed.imported_from_html("some_url")).to eq(expected_html)+ end+ endend