Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

I18n for microsites

Avatar

Community Advisor

Hello Experts

    Need your suggestion on i18n keys management for microsites sharing same code base as main site.

 

Currently we using hints to manage keys for microsite i.e

 

"key: {
"jcr:primaryType": "nt:folder",
"jcr:mixinTypes": [
"sling:Message",
"cq:ReplicationStatus"
],
"sling:message": "MESSAGE",
"sling:key": "key"
},
"key0: {
"jcr:primaryType": "nt:folder",
"jcr:mixinTypes": [
"sling:Message",
"cq:ReplicationStatus"
],
"sling:message": "MESSAGE1",
"sling:key": "key ((MICROSITE1))"
},
"key1: {
"jcr:primaryType": "nt:folder",
"jcr:mixinTypes": [
"sling:Message",
"cq:ReplicationStatus"
],
"sling:message": "MESSAGE2",
"sling:key": "key ((MICROSITE2))"
},

 

This approach creates unnecessary keys even if microsites sharing same message as main site.

Any other suggestions to manage this better?

 

Thanks

Dipti Chauhan

3 Replies

Avatar

Community Advisor

Hi @Dipti_Chauhan 

 

If microsite and mainsite using the same key with same value, cannot we keep only once instance of key and use it?

Let's say we are using i18n using JSON:

 

{
"fNameKey": "First Name",
"fNameLabel": "First Name (optional)",
"lNameKey": "Last Name",
"lNameLabel": "Last Name (optional)"
}

Now if we want to use First Name in both Microsite and Mainsite, we can refer, "fNameKey" in both the site and it can be referred from same code base.

 

Am I missing anything here to understand the ask?

 

Thanks! 

Avatar

Community Advisor

Hi @Asutosh_Jena_ 

  Microsite using same key but different value.

 

Thanks

Dipti

Avatar

Community Advisor

Hi @Dipti_Chauhan 

 

If it's different value then you can use a separate JSON file which can contain the same key with different value and the content can be loaded dynamically based on the locale.

${'key' @ i18n, locale='mainsite'}
${'key' @ i18n, locale='microsite'}

mainsite.json

{
"fNameKey": "First Name",
"fNameLabel": "First Name (optional)",
"lNameKey": "Last Name",
"lNameLabel": "Last Name (optional)"
}  

 microsite.json

{
"fNameKey": "First Name with additional text",
"fNameLabel": "First Name (optional) with additional text",
"lNameKey": "Last Name with additional text",
"lNameLabel": "Last Name (optional) with additional text"
}

 Thanks!