如何指示 AEM 查找特定的资源包翻译 [英] How to instruct AEM to look for a specific resource bundle translations

查看:21
本文介绍了如何指示 AEM 查找特定的资源包翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个网站,代码库是一样的.

I have two websites and code base is same.

站点A站点B

应用程序/公司/组件

如何在 i18n 中为 SiteA、SiteB 选择不同的资源包翻译?

How to pick different resource bundle translations for SiteA, SiteB in i18n ?

谢谢,斯里

推荐答案

能否具体说明一下,这是服务器端翻译还是客户端翻译?对于客户端翻译,我遇到了 OTB ResourceBundleExportServlet 详细问题 这里.

Can you please be specific, is this for server side translations or client side translations? For client-side translations, I had an issue with OTB ResourceBundleExportServlet detailed here.

sling:basename 方式:

  1. 将属性 sling:basename 添加到 mix:language 节点.说 sling:basename="siteA"
  2. 在包查找期间传递基本名称.request.getResourceBundle("siteA", locale);
  3. 这将只返回来自特定基本名称的键.

客户端自定义捆绑导出器:

Client-side custom bundle exporter:

  1. 为 SiteA 和 SiteB 保留单独的字典.例如:/apps/company/sitea/i18n、/apps/company/siteb/i18n.
  2. 如果无法拆分字典,请在标签中保留命名法以识别网站.例如,所有标签都应以 siteA/siteA 为前缀.比如siteA.clickhere、siteB.clickhere
  3. 创建类似于 ResourceBundleExportServlet 的自定义 servlet.保持路径为/libs/company/i18n/dict.
  4. 自定义 servlet 将从 slingrequest 中检查 siteA 或 siteB 并仅返回相应的标签.根据字典路径(步骤 1)或前缀(步骤 2)过滤标签
  5. 创建覆盖到/libs/clientlibs/granite/utils/source/I18n.js.将 urlPrefix 更改为

  1. Keep separate dictionaries for SiteA and SiteB. For example: /apps/company/sitea/i18n, /apps/company/siteb/i18n.
  2. If splitting dictionary is not possible, keep a nomenclature in your labels to identify site. For example all labels should be prefixed with siteA/siteA. Like siteA.clickhere, siteB.clickhere
  3. Create custom servlet similar to ResourceBundleExportServlet. Keep the path as /libs/company/i18n/dict.
  4. The custom servlet will check siteA or siteB from slingrequest and return respective labels only. Filtering the labels based of dictionary path(step 1) or prefix(step 2)
  5. Create overlay to /libs/clientlibs/granite/utils/source/I18n.js. Change the urlPrefix to

var urlPrefix = "/libs/company/i18n/dict.";

var urlPrefix = "/libs/company/i18n/dict.";

现在客户端 i18n 查找将从自定义导出器而不是 OTB 导出器中提取条目

Now the client side i18n lookup will pull entries from the custom exporter rather than OTB exporter

服务器端解析器:

  1. 为了区分 sitea 或 siteb 标签,我们需要上面的第 1 步或第 2 步.
  2. 一旦我们知道要识别特定于站点的标签,我们只需要一个帮助工具来检查请求中的站点并从特定的字典或前缀中解析

希望这会有所帮助.

这篇关于如何指示 AEM 查找特定的资源包翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆