Patch #43379
closedLocalize default commonmark alert titles (note, tip, warning, caution and important)
Added by Florian Walchshofer about 1 month ago. Updated 8 days ago.
0%
Description
Files
| alert_types_localized.patch (747 Bytes) alert_types_localized.patch | Florian Walchshofer, 2025-10-21 22:42 | ||
| alert_types_localized_yml.patch (25.8 KB) alert_types_localized_yml.patch | Florian Walchshofer, 2025-10-21 22:42 | ||
| fix-alert-custom-title.patch (1.79 KB) fix-alert-custom-title.patch | Go MAEDA, 2025-10-29 16:48 | ||
| clipboard-202510292218-ipzbn.png (12 KB) clipboard-202510292218-ipzbn.png | Florian Walchshofer, 2025-10-29 22:18 | ||
| fix-alert-custom-title-v2.patch (1.01 KB) fix-alert-custom-title-v2.patch | Go MAEDA, 2025-10-31 05:01 |
Related issues
Updated by Go MAEDA about 1 month ago
- Target version set to Candidate for next minor release
Updated by Go MAEDA about 1 month ago
- Related to Feature #42603: Enable commonmark alert extension added
Updated by Marius BĂLTEANU about 1 month ago
- Assignee set to Marius BĂLTEANU
- Target version changed from Candidate for next minor release to 6.1.1
Updated by Marius BĂLTEANU about 1 month ago
- Subject changed from localize commonmark alert extension to Localize commonmark alert extension
Updated by Marius BĂLTEANU about 1 month ago
- Status changed from New to Resolved
Committed with a test, thanks!
Updated by Marius BĂLTEANU about 1 month ago
Thanks Go MAEDA for catching the issues introduced by me.
Updated by Go MAEDA about 1 month ago
The translation feature caused an issue where alert box titles were always translated, even when a custom title was specified by the user, like this:
> [!Tip] Useful hint > You can override the default alert box title
With the above example, the displayed title should be "Useful hint", but currently it incorrectly displays the default title "Tip".
The attached patch fixes the issue.
Updated by Florian Walchshofer about 1 month ago
Thanks Go MAEDA i can confirm this patch.

> [!Tip] Useful hint > You can override the default alert box title, ok > [!Tip] > Standard alert box tip in german
Updated by Marius BĂLTEANU about 1 month ago
Go MAEDA, thanks for catching this issue!
I think we can fix it also in one line:
1. node.content = ::I18n.t("label_alert_#{node.content.downcase}", default: node.content): this could lead to an unexpected translation if we add another label_alert_<something> in the future that is not part of the commonmark alerts.
2. node.content = ::I18n.t("label_alert_#{alert_type}", default: node.content) if ALERT_TYPE_TO_ICON_NAME.key?(node.content.downcase)
I'm ok with all three solutions.
Updated by Go MAEDA about 1 month ago
Marius BĂLTEANU wrote in #note-9:
Go MAEDA, thanks for catching this issue!
I think we can fix it also in one line:
1.
node.content = ::I18n.t("label_alert_#{node.content.downcase}", default: node.content): this could lead to an unexpected translation if we add anotherlabel_alert_<something>in the future that is not part of the commonmark alerts.2.
node.content = ::I18n.t("label_alert_#{alert_type}", default: node.content) if ALERT_TYPE_TO_ICON_NAME.key?(node.content.downcase)
Thank you for your refined code suggestions. I think the second option is the best. Checking if node.content.downcase matches a key in ALERT_TYPE_TO_ICON_NAME is not only safe, but also makes it clear that the translation should be done only if node.content is a string like "Note" or "Warning".
I am attaching a patch updated based on the last option.
Updated by Marius BĂLTEANU about 1 month ago
Thanks, I've committed the changes.
Updated by Marius BĂLTEANU about 1 month ago
Great!
I think we can merge now all the fixes to 6.1.1?
Updated by Marius BĂLTEANU about 1 month ago
Go MAEDA wrote in #note-14:
I agree, but there may be some trouble when merging the updates to locale files made in r24078 and r24100. It might be better to skip merging both commits.
It should be fine now, I've merged the revisions without r24078 and r24100 and then I've updated the locales in r24102. Please let me know if you see any issue.
Updated by Marius BĂLTEANU about 1 month ago
- Subject changed from Localize commonmark alert extension to Localize default commonmark alert titles (note, tip, warning, caution and important)
Updated by Marius BĂLTEANU about 1 month ago
- Status changed from Resolved to Closed
Updated by Go MAEDA 22 days ago
- Related to Patch #43468: Bulgarian translation added
Updated by Go MAEDA 22 days ago
- Related to Patch #43471: Traditional Chinese translation (to r 24142) added