Expand my Community achievements bar.

SOLVED

Add variables in i18n label in Sightly HTML

Avatar

Level 5

Hi Team,

I wanted to insert values in i18n label, which I am using in the HTML code:

 

The label should be :

String <<DATE>> String <<PRICE>> EUR

here, date and Price are something, I wanted to use dynamically and wanted to populate in the i18n label. I had gone through the documentation but didn't find it helpful as if how I can make use of it.

 

In my HTML files, I use i18n keys as - 

<p>${ 'organisation.componentgroup.component.element.description' @ i18n }</p>

 If there is any syntax, where I can pass the values - please suggest it!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi ,

How does the site path looks like?

Can you check if you are getting this labels in 

http://localhost:4502/libs/cq/i18n/dict.en.json 

http://localhost:4502/libs/cq/i18n/dict.nl.json 



Arun Patidar

View solution in original post

3 Replies

Avatar

Community Advisor

Please check format

${'Asset {0} out of {1}' @ format=[properties.current, properties.total], i18n, locale='de'}

 



Arun Patidar

Avatar

Level 5

Hi @arunpatidar Thanks for the reply. This works fine with your example string.

 

I have the same label to be used in different languages with different placement of variables based on language. 

I have kept labels in nl.xml/en.xml and fr.xml and I was normally accessing the keys in HTML as - 

${ 'organisation.componentgroup.component.element.description' @ i18n }

E.g., For accessing the key using variables available in HTML. 

for EN and NL - 

Asset {0} out of {1} EUR

for FR - 

Asset {0} out of EUR {1}

Is there any other syntax, which will take the i18n key instead of passing the string directly?

Avatar

Correct answer by
Community Advisor

Hi ,

How does the site path looks like?

Can you check if you are getting this labels in 

http://localhost:4502/libs/cq/i18n/dict.en.json 

http://localhost:4502/libs/cq/i18n/dict.nl.json 



Arun Patidar