Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25784

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

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    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.

      Attachments

        Activity

          People

            surli Simon Urli
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: