Translate a Wiki Macro
Last modified by Eleni Cojocariu on 2026/10/12 13:22
Steps
Translate the name, the description and the parameter labels of a wiki macro so the editor displays them in the reader's interface language.
The macro itself is not modified. The translations are matched to it by the name of the keys, which carry the macro id, and they are written in a translation document like any other translation, see Writing Internationalized XWiki Applications.
- Create a page to hold the translations, add an object of type XWiki.TranslationDocumentClass to it in the object editor, and set its "Scope" to the value that matches the macro's visibility: GLOBAL for a Global macro, WIKI for a Current Wiki macro, USER for a Current User macro.
- Write the keys in the content of that page, one key=value pair per line, with the values in the language the page itself is written in. <macro id> is the "Macro id" field of the macro, <parameter name> the "Parameter name" field of one of its parameters:
Key Translates rendering.macro.<macro id>.name The name the macro is listed under in the editor's macro picker. rendering.macro.<macro id>.description The description displayed under that name, and at the top of the "Edit Macro" dialog. rendering.macro.<macro id>.parameter.<parameter name>.name The label of that parameter's field in the "Edit Macro" dialog. rendering.macro.<macro id>.parameter.<parameter name>.description The help text displayed under that field. rendering.macro.<macro id>.content.description The help text displayed under the macro's "Content" field. - Translate that page into every language you support, and write the values of that language in the translation. The French translation of the hello macro built in Write a Macro in a Wiki Page is:
rendering.macro.hello.name=Macro pour dire bonjour rendering.macro.hello.description=Salue la personne qui lit la page rendering.macro.hello.parameter.greetUser.name=Personnaliser le message rendering.macro.hello.parameter.greetUser.description=Saluer par son nom la personne connectée rendering.macro.hello.content.description=Le texte affiché après la salutation - Save, then open any page in the WYSIWYG editor with the interface in that language. The macro picker lists the macro under its translated name and description, and the "Edit Macro" dialog labels its parameters with theirs:

FAQ
Can I translate a macro I did not write?
Yes. The translations live in a page of your own and nothing on the macro page changes, so what you need is the right the "Scope" of that page calls for, not access to the macro.
Why is my macro still displayed under its untranslated name?
Most often because the translation document does not reach the page you are editing. Its "Scope" has to match the macro's visibility, and the key has to use the macro id, not its name.