Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: MOTION-157
Info

These generic i18n keys are part of the Magnolia 6 UI framework.

If you work with the Magnolia 5 UI framework, see Generic i18n keys for Magnolia 5 UI instead.

This page explains the use of the so-called generic i18n keys or, in other words, keys that Generic i18n keys can be used simultaneously in more than one specific location simultaneously, such as in multiple modules, apps and subapps, multiple tabs , or even in multiple views. A list of such keys is provided at the end of this page.

...

This means that you do not need to provide keys for all UI elements in your app. Keys for commonly reused elements such as buttons and subapps are in Magnolia's own modules. Just reuse the UI element in your app, and Magnolia will find the existing key automatically. In simple terms, the shorter the form of the key, the more places it will be applicable toapply to.

Example: The contact edit form has Save changes and Cancel buttons.

The Contacts app does not provide the text for either button in its own message bundle. They are provided in the module-ui-framework-messages_en.properties file of the ui-framework module.

Code Block
languagepowershell
titlemodule-ui-framework-messages_en.properties
# Default Action Labels
actions.commit=save changes
actions.cancel=cancel

Therefore, it is not necessary to insert two specific keys such as the following into the .properties file of the Contacts app:.

Code Block
languagepowershell
titlecontacts-app-messages_en.properties
contacts-app.actions.commit=save changes
contacts-app.actions.cancel=cancel

If your app needs these buttons, just name your actions commit and cancel.

...

enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

Image Added

...

Mgnl n
actions

...

Mgnl n
commit

...

Mgnl p
class

...

info.magnolia.ui.form.action.SaveFormActionDefinition

...

Mgnl p
implementationClass

...

info.magnolia.contacts.app.form.action.SaveContactFormAction

...

Mgnl n
cancel

...

Mgnl p
class

...

info.magnolia.ui.form.action.CancelFormActionDefinition

Providing a key to other modules or apps

If a key is to be made available to other modules or apps, make the key less - specific , i.e. shorten it, usually by omitting the <module> or <app> part of the key. See the list below for acceptable shorter forms of i18n keys.

Example: The key for the Teaser teaser component in the MTK module (https://demo.magnolia-cms.com/.magnolia/admincentral;#app:resources:detail;/mtk/templates/components/teaser.yaml) 

Code Block
languagehtml/xml
mtk.templates.components.teaser=Teaser

...

By omitting the module name (mtk) in from the key, the shorter form can be reused for translation in other modules, e.g. in the Travel -demo Demo (https://demo.magnolia-cms.com/.magnolia/admincentral;#app:resources:detail;/travel-demo/templates/components/teaser.yaml).

...

There are, however, scenarios when a translation for an element has to be different from the one available in the generic key. In this case, the user still has the option to expand the key from its short (generic) form into a longer pattern which that specifies the element (ie.eg. the module, app, subapp, etc.) where the translation should appear. For example, if the key for the Teaser teaser component in the Travel -demo Demo module needed needs a different translation than from that used in MTK, the key can be expanded into a more specific form:

...

The translation will now be available primarily to the teaser component in the Travel Demo module.

...

  • [<app>.][<subapp>.]views.numerator<column>[.label]

(warning) If used in the key, <subapp> requires <app>.

...

Tabs

  • <module>.<dialogPath>.<tab>[.label]
  • dialogstabs.<dialogPath><tab>[.label]

Chooser dialogs

Dialogs

  • <module>.<dialogPath>
  • Generic: dialogs.chooseDialog[.label]
  • App-specific: <app>.chooseDialog[.label] Action
  • -specific: dialogs.<action><dialogPath>[.label]

...

Fields

  • <module>fields.<dialogPath>.<tab><field>[.label]
  • tabs<app>.<action>.<tab><field>[.label]

...

Select fields

  • Generic: fields.<field>.options[.label]
  • App-specific: <app>.<action>.<field>.options[.label]

Field validators

The generic i18n key form for a field validator is validators.<validatorName>.errorMessage.

...

  • [<module>.]<dialogPath>.[<tab>.]<field>.validation.errorMessage
  • <tab>.<field>.validation.errorMessage
  • fields.<field>.validation.errorMessage

Templates

Pages/components

  • [<module>.]templates.<templatePath>
  • [<module>.]templates.<templatePath>.description

Areas

  • templates.areas.<areaName>
  • templates.areas.<areaName>.description