Load a key from specific i18n Dictionary via sightly

Avatar

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

234 likes

Total Posts

295 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

234 likes

Total Posts

295 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile
Shashi_Mulugu
MVP

11-11-2020

Hello Community Members,

 

A quick question, We have multi-tenant application, where we i18n dictionary for having same keys but different meanings, ex "welcome_message": "Welcome to My Site", in TenantA, where as for in TenantB, "welcome_message": "Welcome to My SiteB", So i dont have any Javabased logic and i am using simple sightly to display them.

${'welcome_message' @ i18n}

 So based on above, i am getting TenantB msg in TenantA.

 

Is there a way to load a specific dictionary values via sightly?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

234 likes

Total Posts

295 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

234 likes

Total Posts

295 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile
Shashi_Mulugu
MVP

13-11-2020

Yes after doing a deep dive we can't simply do this from sightly, so I have used sling model to load a specific dictionary using sling:basename at dictionary level and using resourcebundle to load specific dictionary by passing locale and basename as params.

 

Thanks members for the insights.

Answers (3)

Answers (3)

Avatar

Avatar
Give Back
Level 4
Jineet_Vora
Level 4

Likes

42 likes

Total Posts

45 posts

Correct reply

22 solutions
Top badges earned
Give Back
Ignite 1
Boost 5
Boost 3
Boost 25
View profile

Avatar
Give Back
Level 4
Jineet_Vora
Level 4

Likes

42 likes

Total Posts

45 posts

Correct reply

22 solutions
Top badges earned
Give Back
Ignite 1
Boost 5
Boost 3
Boost 25
View profile
Jineet_Vora
Level 4

12-11-2020

Hi @Shashi_Mulugu,

Per Adobe documentation it is beyond the control of developer if there is more than one same key having different values. The reason is that the JSON for i18n is compiled altogether in a single file which includes all dictionaries under /apps and /libs.

So I believe there is no way to distinguish the key based on the project.

https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/internationaliza...

 

Note that you cannot predict which translation is used when strings are duplicated in dictionaries that are all located below the /apps node.

 

Image source: Adobe


chlimage_1-10a_c1.png

 

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

12-11-2020

Yeah, as @Jineet_Vora said we cannot achieve this. Data Dictionary is just like Map, keys cannot be duplicated. If we duplicate the latest one will override the previous one. Similarly here the key which is down below the repository hierarchy will override the previous key.

/apps/project/a/i18n - KEY_ONE

/apps/project/b/i18n - KEY_ONE

KEY_ONE in b/i18n will override the KEY_ONE of a/i18n, as /project/b comes below in repo the hierarchy.

 

AG

Avatar

Avatar
Validate 1
Level 3
prashantonkar
Level 3

Likes

17 likes

Total Posts

51 posts

Correct reply

7 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Validate 1
Level 3
prashantonkar
Level 3

Likes

17 likes

Total Posts

51 posts

Correct reply

7 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back
View profile
prashantonkar
Level 3

12-11-2020

It may not solve your exact use-case, but will this be of any help?

https://stackoverflow.com/questions/48619497/how-to-give-preference-to-a-particular-dictionary-in-si...