This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-428d60d7-0730-45e7-97b1-f14733486e8d XWIKI-25784 Open

Gadget titles show the raw translation macro when the macro id contains a hyphen

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-e4b95e79-2628-492d-af80-f9a7978b0f0b Vincent Massol created this issue on 17/Nov/26 12:24
 
Summary: Gadget titles show the raw translation macro when the macro id contains a hyphen
Issue Type: cid:jira-generated-image-avatar-428d60d7-0730-45e7-97b1-f14733486e8d Bug
Affects Versions: 16.10.18, 17.10.9, 18.4.0
Assignee: Unassigned
Components: Dashboard
Created: 17/Nov/26 12:24
Priority: cid:jira-generated-image-static-major-9ea95f9f-07ac-4370-8f35-bdb5ec7ccf6b Major
Reporter: Vincent Massol
Description:

Steps to reproduce

  1. Install an extension providing a macro whose id contains a hyphen (e.g. the openproject-news macro of the OpenProject Integration), or any macro with an id such as my-macro.
  2. Edit a dashboard, click "Add gadget" and add that macro.
  3. Save and view the dashboard.

Expected

The gadget title is the translated name of the macro.

Actual

The gadget title displays the raw macro call, e.g. {{translation key="rendering.macro.openproject-news.name"/}}

Cause

The gadget wizard (gadgetWizard.js) sets the default title to {{translation key="rendering.macro.<macroId>.name"/}}, but DefaultGadgetSource renders a title with the translation macro only when it matches TRANSLATION_MACRO_PATTERN, whose key part is [a-zA-Z0-9.]+. Keys containing a hyphen (or an underscore), which are valid in macro ids and translation keys, don't match, so the title is rendered as plain text. TRANSLATION_SCRIPT_PATTERN has the same restriction.

Suggested fix

Accept the characters allowed in translation keys and macro ids (at least - and _) in both patterns.

Workaround

Edit the gadget and replace its title.