FIX: update translation key to match flag reason. (#14573)

FIX: update translation key to match flag reason. (#14573)

The refactor introduced in FIX: Make score's reason link building more explicit by romanrizzi · Pull Request #14475 · discourse/discourse · GitHub made this visible. Adds a safeguard to make sure translation is present before trying to linkify backticks.

diff --git a/app/serializers/reviewable_score_serializer.rb b/app/serializers/reviewable_score_serializer.rb
index 143239b..a16bd75 100644
--- a/app/serializers/reviewable_score_serializer.rb
+++ b/app/serializers/reviewable_score_serializer.rb
@@ -6,7 +6,7 @@ class ReviewableScoreSerializer < ApplicationSerializer
     trust_level: 'approve_unless_trust_level',
     new_topics_unless_trust_level: 'approve_new_topics_unless_trust_level',
     fast_typer: 'min_first_post_typing_time',
-    auto_silence_regexp: 'auto_silence_first_post_regex',
+    auto_silence_regex: 'auto_silence_first_post_regex',
     staged: 'approve_unless_staged',
     must_approve_users: 'must_approve_users',
     invite_only: 'invite_only',
@@ -40,11 +40,12 @@ class ReviewableScoreSerializer < ApplicationSerializer
       text = I18n.t("reviewables.reasons.#{object.reason}", link: link, default: nil)
     else
       text = I18n.t("reviewables.reasons.#{object.reason}", default: nil)
+
       # TODO(roman): Remove after the 2.8 release.
       # The discourse-antivirus and akismet plugins still use the backtick format for settings.
       # It'll be hard to migrate them to the new format without breaking backwards compatibility, so I'm keeping the old behavior for now.
       # Will remove after the 2.8 release.
-      linkify_backticks(object.reason, text)
+      linkify_backticks(object.reason, text) if text
     end
 
     text
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 8c93681..84dbbcd 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -5001,7 +5001,7 @@ en:
       trust_level: "Users at low trust levels must have replies approved by staff. See %{link}."
       new_topics_unless_trust_level: "Users at low trust levels must have topics approved by staff. See %{link}."
       fast_typer: "New user typed their first post suspiciously fast, suspected bot or spammer behavior. See %{link}."
-      auto_silence_regexp: "New user whose first post matches the %{link} setting."
+      auto_silence_regex: "New user whose first post matches the %{link} setting."
       watched_word: "This post included a Watched Word. See your %{link}."
       staged: "New topics and posts for staged users must be approved by staff. See %{link}."
       category: "Posts in this category require manual approval by staff. See the %{link}."
diff --git a/spec/serializers/reviewable_score_serializer_spec.rb b/spec/serializers/reviewable_score_serializer_spec.rb
index 8c82085..50f6a91 100644
--- a/spec/serializers/reviewable_score_serializer_spec.rb
+++ b/spec/serializers/reviewable_score_serializer_spec.rb
@@ -29,7 +29,7 @@ describe ReviewableScoreSerializer do
 
     context 'site setting links' do
       reasons = %w[
-        post_count trust_level new_topics_unless_trust_level fast_typer auto_silence_regexp
+        post_count trust_level new_topics_unless_trust_level fast_typer auto_silence_regex
         staged must_approve_users invite_only email_spam suspect_user contains_media
       ]
 

GitHub sha: 7bc7e1aceb0a68c90c41e19f3c0364195bcddd34

This commit appears in #14573 which was approved by OsamaSayegh. It was merged by romanrizzi.