【问题标题】:Own internationalization support in sightly自己的国际化支持在望
【发布时间】:2015-09-24 08:47:22
【问题描述】:

在我正在研究的项目中,未使用标准 i18n 国际化。而是在前一段时间创建了一个自定义的。

现在随着在 AEM 6.1 上的迁移,我们希望使用 Sightly,但仍使用我们自己的自定义系统。很明显有i18n support,我想知道是否可以为我们自己的系统创建类似的东西。

我尝试使用模板,但很难在不同的数据标签中使用它们然后调用。 (例如 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 接口 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>

如果您对此问题有任何疑问,请随时提出。

【问题讨论】:

    标签: java internationalization aem sightly


    【解决方案1】:

    您不能定义自己的视觉标签。您最多可以做的是利用 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>
    

    【讨论】:

      猜你喜欢
      • 2015-07-13
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 2013-10-14
      • 2012-06-06
      • 2021-03-28
      • 1970-01-01
      相关资源
      最近更新 更多