Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

i18n picking from libs/cq/i18n/dict ...

Avatar

Level 4

I have project specific i18n keys but those values are overriding from /libs/cq/i18n/dict..

Usually from where this values comes from ?

How we  can stop  overriding?

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

Solution:

I have multiple projects in my env ,every project has there own i18n files but few projects using same keys what I used in my project  with different values each project using.

/libs/cq/i18n/dict.en_us .json ,creating keys and values  ,picking from all project without duplicating keys so which project is deployed  latest in env that values getting updated in  dict that's why it is getting overridden.

 

View solution in original post

8 Replies

Avatar

Community Advisor

@user96222 You can overlay /libs/cq/i18n/dict to /apps/cq/i18n/dict to avoid overriding. 

For Project specific overlay follow below screenshot and snippet:

Imran__Khan_0-1708685940368.png

 

i18n .content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" 
          xmlns:jcr="http://www.jcp.org/jcr/1.0" 
          xmlns:rep="internal"
    jcr:mixinTypes="[rep:AccessControllable]"
    jcr:primaryType="sling:Folder"/>

 

en.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
  xmlns:cq="http://www.day.com/jcr/cq/1.0"
  xmlns:jcr="http://www.jcp.org/jcr/1.0"
  xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
  xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:language="fr"
    jcr:mixinTypes="[mix:language]"
    jcr:primaryType="nt:folder">
    <hello.world
        jcr:mixinTypes="[sling:Message]"
        jcr:primaryType="nt:folder"
        sling:message="Bonjour le monde"/>
</jcr:root>

 

Avatar

Community Advisor

Hi @user96222 ,

Ensure you are following correct approach to create i18n specific folder correctly in your project.
It should be something like below, its only for "en" language:

i18n
   en.json.dir -- jcr:primaryType="nt:file"
   en.json.


Thanks
Tarun

Avatar

Community Advisor

You need to create project-specific dictionaries .You can define dictionaries at different levels (e.g., project, component, page) to override these defaults with translations specific to your project. e.g /apps/[Custom Project Name]/[Custom Folder Name]/i18n

Thanks

Dipti

Avatar

Level 4

@Imran__Khan @TarunKumar @Dipti_Chauhan 

I have multiple repos ,each repo has there own  i18n folders and structure ,has no issues.its working as expected!

But few repos using same keys  with different values.

  from where i18n  keys and values comes for   libs/cq/i18n/dict.en_us.json ?

As my understanding it checking all repos and creating keys and values in libs/cq/i18n/dict.en_us.json without duplication .

Here is key is constant but value from  which repo it will pick?

Is latest deployed repo or any format?

Avatar

Community Advisor

@user96222 We faced same issue three years back wehre we wanted to had same keys with different values. This will not work and you need to create unique keys as if you notice our servlet response always provide one json for all the fields. This means it will accept only one key like a set in Java. If we write same key multiple times, it will get override.

The correct way is to always provide value depends on repo to uniquely indetify the keys like projectname.hello="hello"

Avatar

Administrator

@user96222 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Correct answer by
Level 4

Solution:

I have multiple projects in my env ,every project has there own i18n files but few projects using same keys what I used in my project  with different values each project using.

/libs/cq/i18n/dict.en_us .json ,creating keys and values  ,picking from all project without duplicating keys so which project is deployed  latest in env that values getting updated in  dict that's why it is getting overridden.