如何指示AEM查找特定的资源包翻译 [英] How to instruct AEM to look for a specific resource bundle translations
问题描述
我有两个网站,代码库是相同的.
I have two websites and code base is same.
SiteASiteB
SiteA SiteB
apps/company/components
apps/company/components
如何在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 方式:
- 将属性sling:basename添加到mix:language节点.说sling:basename ="siteA"
- 在分发包查找期间传递基本名称.request.getResourceBundle("siteA",locale);
- 这将仅返回来自特定基本名称的密钥.
客户端自定义包导出器:
Client-side custom bundle exporter:
- 为SiteA和SiteB保留单独的词典.例如:/apps/company/sitea/i18n,/apps/company/siteb/i18n.
- 如果无法拆分字典,请在标签中保留一个命名法以标识站点.例如,所有标签都应以siteA/siteA为前缀.像siteA.clickhere,siteB.clickhere
- 创建类似于ResourceBundleExportServlet的自定义servlet.保持路径为/libs/company/i18n/dict.
- 自定义servlet将通过slingrequest检查siteA或siteB并仅返回各自的标签.根据字典路径(步骤1)或前缀(步骤2)过滤标签
-
为/libs/clientlibs/granite/utils/source/I18n.js创建覆盖.将urlPrefix更改为
- Keep separate dictionaries for SiteA and SiteB. For example: /apps/company/sitea/i18n, /apps/company/siteb/i18n.
- 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
- Create custom servlet similar to ResourceBundleExportServlet. Keep the path as /libs/company/i18n/dict.
- 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)
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
服务器端解析器:
- 要区分sitea或siteb标签,我们需要从上方进行步骤1或2.
- 一旦我们知道要标识站点特定的标签,我们只需要一个助手实用程序即可根据请求检查站点并根据特定的字典或前缀进行解析
希望这会有所帮助.
这篇关于如何指示AEM查找特定的资源包翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!