Internationalization of the Magnolia Freemarker templates

Internationalization of the Magnolia Freemarker templates

To extend the contents of Magnolia CMS – we have created several custom paragraphs. Once we need a localization for these paragraphs – we’ve tried a usual approach used in STK. So we’ve written something like

${i18n['custom.goToTop']}

in the FreeMarker template and got the following error immediately:
freemarker.core.InvalidReferenceException: Expression i18n is undefined on …

What the hell, our template is similar to the STK paragraphs? Later it appeared that we’re missing one important property in the paragraph metadata called i18nBasename. Exactly this parameter allows template to use parameter called i18n.