1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-11 13:15:20 +00:00

Localize default commonmark alert titles (#43379).

Patch by Go MAEDA (user:maeda) and Marius BALTEANU (user:marius.balteanu).



git-svn-id: https://svn.redmine.org/redmine/trunk@24093 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2025-10-31 06:32:31 +00:00
parent 79a411163d
commit 19927b2382
2 changed files with 16 additions and 2 deletions

View File

@ -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)

View File

@ -52,5 +52,16 @@ if Object.const_defined?(:Commonmarker)
expected = %r{<span class="icon-label">#{I18n.t('label_alert_note')}</span>}
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{<span class="icon-label">Custom Note Title</span>}, html
end
end
end