Reputation: 171
In the projekt i'm working on the standart i18n internationalization is not used. Rather a custom one was created some time ago.
Now with migrating on AEM 6.1 we want to use Sightly but still use our own custom system. In sightly there is i18n support and i was wondering if it is possible to create something similar for our own system.
I tried to use templates but struggled to use them in different data-sly tags then call. (e.g. data-sly-attribute) Do i make a mistake here?
template.html
<template data-sly-template.foo="${ @ key }">bar</template>
<sly data-sly-call="${ foo }" data-sly-unwrap></sly>
<div data-sly-attribute="${ foo }"></div>
output.html
bar
<div></div>
I tried to make something work with the java interface RuntimeExtension but it did not work.
Our system is basically a xml file with tags and strings. I can get the data from there without a problem with a service.
Example:
<en>
<com.example.title jcr:primaryType="nt:unstructured" value="A title"/>
<com.example.desc jcr:primaryType="nt:unstructured" value="Description"/>
</en>
<de>
<com.example.title jcr:primaryType="nt:unstructured" value="Ein Tiel"/>
<com.example.desc jcr:primaryType="nt:unstructured" value="Beschreibung"/>
</de>
If you have any questions regarding the problem feel free to ask.
Upvotes: 0
Views: 707
Reputation: 1161
You cannot define own sightly tags. What you at most can do is to take advantage of the use directive and use another template as your custom tag. You can basically look at working example under /libs/granite/sightly/templates/clientlib.html which follows basically the following structure: .html
<template data-sly-template.customi18n="${@ i18nkey}">do something here</template>
.html
<div data-sly-use.i18n="${'/path/to/templates/customi18n.html'}" data-sly-unwrap>
<span data-sly-call="${i18n.customi18n @ i18nkey='My Translation Key'}" data-sly-unwrap></span>
</div>
Upvotes: 2