在我正在研究的项目中,未使用标准 i18n 国际化。相反,自定义的一个是前一段时间创建的。
现在,在 AEM 6.1 上迁移后,我们希望使用 Sightly,但仍使用我们自己的自定义系统。一眼望去有i18n support我想知道是否有可能为我们自己的系统创建类似的东西。
我尝试使用模板,但很难在不同的 data-sly 标签中使用它们,然后调用。 (例如 data-sly-attribute)我在这里犯错了吗?
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>
我试图让一些东西与java接口(interface)一起工作RuntimeExtension但没有成功。
我们的系统基本上是一个带有标签和字符串的 xml 文件。我可以从那里获取数据,服务不会出现问题。
示例:
<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>
如果您对此问题有任何疑问,请随时提问。
最佳答案
您无法定义自己的视觉标签。您最多可以做的是利用 use 指令并使用另一个模板作为您的自定义标记。您基本上可以查看/libs/granite/sightly/templates/clientlib.html 下的工作示例,它基本上遵循以下结构: .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>
关于java - 自己的国际化支持就在眼前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32757090/