AEM has been one of the market leaders in Content Management space for many years now. Many of those who get started with AEM in any role get to hear about i18n keys concept. The i18n is abbreviation for Internationalization. (If you are wondering how they came up with this abbreviation, check this answer on Stack Overflow to know about it)
Placement of i18n Keys:
Every AEM Project has an i18n folder under /apps which is responsible for storing the i18n keys for the strings that you want to use in the components for your site. The i18n keys are stored in json files which are named according to the locales. For example, the default i18n file is en.json and if your project needs translation in other languages like German, French, then for each language there will be a separate json file like de.json, fr.json etc.
The i18n concept in AEM is about defining keys as placeholder and providing the text value to each key for its use on any component in AEM. For example, look at an example of one key below in the json file –
“form_first_name_label” : ”First Name”
where form_first_name_label is the key and “First Name” is its value.
By defining above i18n key, we can use its value anywhere in any component instead of hardcoding the text in multiple components.
What are the advantages?
So, a question arises, what is the advantage of storing the text as i18n instead of putting it directly in the component html file. The answer to this is –
- Re-usability: The same string might be needed in multiple components and if it is stored as i18n keys, those can be defined once and used at multiple places. So, in future, if that text needs to be changes, the change is needed only in i18n key and all the components which were using it will reflect the change without changing in every component.
- Translation: The main use of storing i18n keys is to support translation of the text in multiple languages. If your project needs a translation of the website into multiple languages, i18n keys need to be defined for all those languages in their respective json files. The creation of other language i18n json files is usually automated by use of external translation services but can be done manually as well.
For more posts related to AEM, subscribe to our blog.