diff --git a/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter.rb b/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter.rb index 73a09b15f..595c6cf58 100644 --- a/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter.rb +++ b/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter.rb @@ -48,8 +48,11 @@ module Redmine icon_name = ALERT_TYPE_TO_ICON_NAME[alert_type] next unless icon_name # Skip if no specific icon is defined for this alert type - # label alert translation - node.content = ::I18n.t("label_alert_#{alert_type}", default: node.content) + # Translate the alert title only if it matches a known alert type + # (i.e., the title has not been overridden) + if ALERT_TYPE_TO_ICON_NAME.key?(node.content.downcase) + node.content = ::I18n.t("label_alert_#{alert_type}", default: node.content) + end icon_html = ApplicationController.helpers.sprite_icon(icon_name, node.text) diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter_test.rb index 099c7a486..43abfc5f7 100644 --- a/test/unit/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter_test.rb @@ -52,5 +52,16 @@ if Object.const_defined?(:Commonmarker) expected = %r{#{I18n.t('label_alert_note')}} assert_match expected, html end + + def test_should_not_translate_title_if_overridden + set_language_if_valid 'de' + text = <<~MD + > [!note] Custom Note Title + > This is a note. + MD + html = filter(format(text)) + assert_match %r{Custom Note Title}, html + end + end end