Tushar
Tushar

Reputation: 151

Generate dynamic key in i18n AEM

I have requirement for having a dynamic key for getting value in i18n. I am using sightly. i would be having the initial part of the key but the last part i have to attach dynamically and then allow sightly to get the value for the same. Could you please help me on it.

Upvotes: 0

Views: 596

Answers (1)

chrysler
chrysler

Reputation: 458

I guess best practice would be to have a getter at some component-bean to avoid as much programming logic within the markup as possible. If you like/need to put the logic into the html anyway try something similar to this:

<p data-sly-test.keyPostfix="${isTrue ? 'true text' : 'false text'}" 
   data-sly-test.i18nKey="${['some.i18n.key', keyPostfix] @ join='.'}"
   data-sly-text="${i18nKey @ i18n}">This text will be replaced by sly-text!</p>

Upvotes: 2

Related Questions