Skip to content

A platform for community discussion. Free, open, simple.

FIX: Use default locale for temporarily_closed_due_to_flags (#34718)

Krzysztof Kotlarekc16d1e717ad6
diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rb
index 72a2daecf02..2669fb8e3b8 100644
--- a/lib/post_action_creator.rb
+++ b/lib/post_action_creator.rb
@@ -225,7 +225,11 @@ class PostActionCreator
true,
Discourse.system_user,
message:
- I18n.t("temporarily_closed_due_to_flags", count: SiteSetting.num_hours_to_close_topic),
+ I18n.t(
+ "temporarily_closed_due_to_flags",
+ count: SiteSetting.num_hours_to_close_topic,
+ locale: SiteSetting.default_locale,
+ ),
)
topic.set_or_create_timer(
diff --git a/spec/lib/post_action_creator_spec.rb b/spec/lib/post_action_creator_spec.rb
index 4d31b62ce51..44a07de6629 100644
--- a/spec/lib/post_action_creator_spec.rb
+++ b/spec/lib/post_action_creator_spec.rb
@@ -166,6 +166,21 @@ RSpec.describe PostActionCreator do
expect(score.reviewed_at).to be_blank
end
+ it "uses the system locale for the message when auto close" do
+ Topic.any_instance.stubs(:auto_close_threshold_reached?).returns(true)
+ I18n.with_locale(:fr) { PostActionCreator.create(user, post, :inappropriate) }
+
+ post.topic.reload
+
+ expect(post.topic.posts.last.raw).to eq(
+ I18n.t(
+ "temporarily_closed_due_to_flags",
+ count: SiteSetting.num_hours_to_close_topic,
+ locale: :en,
+ ),
+ )
+ end
+
describe "Auto hide spam flagged posts" do
before do
user.trust_level = TrustLevel[3]