@ join, i18n does not work | Community
Skip to main content
sreedobe
Level 4
Jul 16, 2019 10:42 PM UTC
Solved

@ join, i18n does not work

I am trying to combine two strings and apply i18n on combined string.

${['i18nPrefix','Register'] @join='-', i18n}

Above piece of code not working and I tried combination of format, i18n etc.

I need to prepend a prefix based on site user visiting to the authored dialog property and get i18n translation.

There are scenarios where a default key need to be appended to prefix. The following has been tried and not working.

<sly data-sly-test.altKey="${'{0}-{1}' @ format=['i18nPrefix', properties.alt ? properties.alt : 'default' ]}" />

Use case : <img alt="prefixedtranslation">, <div aria-label="prefixedtranslation">text</div>, <label>prefixedtranslation</label>

Any help appreciated.

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Jul 17, 2019 11:49 PM UTC

you can try like below, works for me:

<sly data-sly-test.altKey1="${'i18nPrefix' @ i18n}" />

<sly data-sly-test.altKey2="${properties.alt ? properties.alt : 'default' }" />

      ${altKey1}-${altKey2}

Arun Patidar

3 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Jul 17, 2019 11:49 PM UTC

you can try like below, works for me:

<sly data-sly-test.altKey1="${'i18nPrefix' @ i18n}" />

<sly data-sly-test.altKey2="${properties.alt ? properties.alt : 'default' }" />

      ${altKey1}-${altKey2}

Translate
Arun Patidar
sreedobe
sreedobeAuthor
Level 4
Jul 17, 2019 5:51 PM UTC

Thanks Arun.

1. format works, but not in combination with @ format, i18n

2. <img alt="prefixedtranslation">, <div aria-label="prefixedtranslation">text</div> , I can not put / use sly tags inside quotes, If I wanted to achieve combination of format, i18n on two strings how do I do that.

Translate
arunpatidar
New Participant
Jul 16, 2019 11:46 PM UTC

Hi,

Could you please tell which AEM version are you using?

I tried below in 6.3 and it works.

<sly data-sly-test.altKey="${'{0}-{1}' @ format=['i18nPrefix', properties.alt ? properties.alt : 'default' ]}" />

${altKey}

Translate
Arun Patidar