diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rb index 18e154e977..1d5676e5d9 100644 --- a/app/models/topic_embed.rb +++ b/app/models/topic_embed.rb @@ -23,7 +23,9 @@ class TopicEmbed < ActiveRecord::Base end def self.imported_from_html(url) - "\n
\n#{I18n.t('embed.imported_from', link: "#{url}")}\n" + I18n.with_locale(SiteSetting.default_locale) do + "\n
\n#{I18n.t('embed.imported_from', link: "#{url}")}\n" + end end # Import an article from a source (RSS/Atom/Other) diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb index a63c9eaef4..a112a126ff 100644 --- a/spec/models/topic_embed_spec.rb +++ b/spec/models/topic_embed_spec.rb @@ -399,4 +399,18 @@ RSpec.describe TopicEmbed do end end + 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 + end end