How to avoid translated i18n keys getting overridden?

In this post, we will discuss how to avoid translated i18n keys getting overridden through build. If you are wondering, what are i18n keys are AEM, read another post where I go through the concept of i18n keys in AEM.

For AEM projects which are using third-party translation services, the translated i18n keys are auto generated by third-party services which take the English i18n keys are inputs and then create the corresponding locale specific json files automatically.

/apps/customproject/i18n/en.json -> Deployed through code

/apps/customproject/i18n/de.json -> Auto-generated through third-party translation mechanism

/apps/customproject/i18n/fr.json -> Auto-generated through third-party translation mechanism

The en.json is supposed to be deployed through code build from ui.apps package of your project code, however you need a filter so that the other auto-generated i18n json files are NOT overridden by the build. For that you can use the updated filter in your filter.xml file for ui.apps project which would prevent that from happening –

<?xml version=“1.0” encoding=“UTF-8”?>

<workspaceFilter version=“1.0”>

    <filter root=“/apps/customproject”>

       <exclude pattern=“/apps/customproject/i18n/(?!(en.json)$).*” />

    </filter>

</workspaceFilter>

Above filter tells AEM to deploy only en.json file present inside i18n folder in your apps project and skip everything else which basically avoids overriding other language i18n json files.

For more posts related to AEM, subscribe to our blog.

GoPro Hero 8 Black CHDHX-801 12 MP Action Camera

Leave a comment

Your email address will not be published.