Project

General

Profile

Patch #43379 » fix-alert-custom-title.patch

Go MAEDA, 2025-10-29 16:48

View differences:

lib/redmine/wiki_formatting/common_mark/alerts_icons_filter.rb
49 49
            next unless icon_name # Skip if no specific icon is defined for this alert type
50 50

  
51 51
            # label alert translation
52
            node.content = ::I18n.t("label_alert_#{alert_type}", default: node.content)
52
            label_key = "label_alert_#{alert_type}"
53
            # Only translate if the default title has not been overridden
54
            if node.content == ::I18n.t(label_key, locale: :en)
55
              node.content = ::I18n.t(label_key, default: node.content)
56
            end
53 57

  
54 58
            icon_html = ApplicationController.helpers.sprite_icon(icon_name, node.text)
55 59

  
test/unit/lib/redmine/wiki_formatting/common_mark/alerts_icons_filter_test.rb
52 52
      expected = %r{<span class="icon-label">#{I18n.t('label_alert_note')}</span>}
53 53
      assert_match expected, html
54 54
    end
55

  
56
    def test_should_not_translate_title_if_overridden
57
      set_language_if_valid 'de'
58
      text = <<~MD
59
        > [!note] Custom Note Title
60
        > This is a note.
61
      MD
62

  
63
      html = filter(format(text))
64
      assert_match %r{<span class="icon-label">Custom Note Title</span>}, html
65
    end
55 66
  end
56 67
end
(3-3/5)