April 26, 2020
Estimated Post Reading Time ~

Customize languages in AEM 6.2

Adobe Experience Manager is completely flexible and can be configured for any language. AEM inherently understands all ISO language codes, both 2 letter locales (en, fr, de) as well as 5 letter locales (en-US, fr-FR, de-DE).

Language codes play a most important role while you create and translate the site in multiple languages. As per W3C standards, you should use dashes in the locale codes when they are part of the url structure, like de-de, fr-fr, etc. For reference, see Language tags in HTML and XML.

In AEM 6.2 when you create language copies using the References Panel, you will be able to create sites with language codes that have dashes in the language codes. However, when you try to translate those pages using Translation Projects, you will not be able to create Translation Projects, if the language codes do not match the ones in the Translation Project.
Translation Projects in AEM come with a list of pre-configured languages and associated language codes, however, these codes do not follow the W3C standards. If you are curious, you can find the list of languages here: /libs/wcm/core/resources/languages. If you wish to change this list, either for adding more languages or use W3C standard locales for the same languages, you would need to make modifications to this list. As we all know, we should never change anything under /libs. What we should instead do is, override the list in /apps.

In the following step by step procedure, I will walk you through how to override languages in AEM Projects.

Prerequisite:
Before we go ahead with the procedure, you will need to patch to AEM 6.2. Please download cq-6.2.0-hotfix-11808 from Package Share and install it in your instance.

OOTB languages in AEM Projects:
The list of available languages can be seen in the advanced properties tab of the Translation Project.



As you would see, all the language codes are dashes.
We are going to make two changes:
Change underscores in language codes (de_de) to dashes (de-de)
Add an additional Indian language. We will add Punjabi (pa).

Steps:
  • In order to make these changes, we will need to make changes in CRXDE.
  • Open up CRXDE (http://localhost:4502/crx/de/index.jsp) and then browse to /libs/wcm/core/resources/languages
  • Here you will see the list of languages that you see in the Translation Project. The language list is sorted by language code and not language name.
  • Note: Please DO NOT MAKE CHANGES in this list. /libs is restricted and the changes can be overwritten by AEM installers.
  • We will override this list in /apps. We will follow the same path as in libs, but just replace libs with /apps.
  • Browse to /apps/wcm in CRXDE. You would observe that we do not have a core folder under wcm. We will need to recreate the rest of the structure.
  • Create a new folder names core, under /apps/wcm, and Save All.
  • Now we will go back to the resources folder under /libs. Browse to (/libs/wcm/core/resources). Select the resources node and Copy it.
  • Now browse back to the core folder under /apps (/apps/wcm/core); select core and paste the copied content here and then Save All.
  • Note: In case you see an error, it is because you have not saved the core folder, that we created in the previous step.
  • Next, we will iterate over all the language nodes and replace underscores “_” with dashes “-”, do that “de_de” will be replaced with “de-de”.




BEFORE AFTER
Next, we will add the additional Indian language Punjabi (pa). For doing so we will need to create a new node and name it pa.

The node will get added at the bottom of the languages list. Once the node is created, add two properties, both of string type, language and country, as shown below:


Save all the changes and restart AEM.
Now when you create a new project, you shall see the updated list of language codes, with dashes instead of underscores.


You will also be able to see the newly added language: Punjabi



Hence using this procedure, you can update the list of languages as well as codes in Translation Projects.



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.