我可以获得特定字典的整个 i18n 标签吗 [英] Can I get entire i18n labels of specific dictionary
问题描述
我遇到了 i18n 标签的问题.
I am facing an issue with i18n labels.
我的应用程序使用 Granite.I18n.get('') 函数在 js 前端读取了几个 i18n 标签.整个字典被下载为/libs/cq/i18n/dict.{+locale}.json",如/etc/clientlibs/foundation/shared/source/init.js"中所述.
My application reads few i18n labels at js frontend using Granite.I18n.get('') function. The entire dictionary gets downloaded as ‘/libs/cq/i18n/dict.{+locale}.json’ as dictated in ‘/etc/clientlibs/foundation/shared/source/init.js’.
现在 en 字典只返回自定义标签并且尺寸很小.但是像fr这样的其他语言,字典文件是所有/libs字典的集合,非常庞大.我在其他几个网站上也注意到了这一点.
Now the en dictionary returns only the custom labels and is small size. But other languages like fr,the dictionary file is aggregation of all /libs dictionary and is very huge. I noticed this in few other sites also.
tennantco.com
tennantco.com
英文词典 - 118 KB
fr 字典 - 1.4 MB
Timewarnercable.com
Timewarnercable.com
英文词典 - 1.1 KB
fr 字典 - 1.2 MB
热鱼
英文词典 - 3 KB
fr 字典 - 695 KB
我们的痛点是,在 CDN 上缓存这个大文件的成本会增加,并试图找到降低 CDN 成本的方法.
Our pain point with this is, cost of caching this heavy file at CDN increases and trying to find a way to reduce CDN cost.
我知道标签本身就是关键.但是 ExportServlet 只能过滤掉 en 的呈现自定义字典.我们的字典类似于/libs 下的 otb 字典.那么ExportServlet是如何处理en export下的otb标签的呢?
I understand en labels are the key itself. But the ExportServlet is able to filter out the render custom dictionary only for en. Our dictionaries are similar to otb dictionaries under /libs. Then how come ExportServlet treat otb labels under en export?
此错误在所有 CMS 产品中都很常见还是特定于 Adobe?还需要一个解决方案或解决方法来获取仅适用于其他语言的自定义词典.
Is this bug common in all CMS products or specific to Adobe? Also need a solution or workaround to get custom dictionary only for other languages.
推荐答案
我最终编写了一个自定义实现,因为我在这个问题上也没有从 Adobe 票证中获得太多帮助.
I ended up writing a custom implementation as I didnt get much help from Adobe tickets as well on this issue.
- OTB 字典 json 由 ResourceBundleExportServlet 渲染
- 我创建了一个自定义的 sling servlet,它将准备和返回类似于 ResourceBundleExportServlet 的 json
- 修改/etc/clientlibs/granite/utils/source/I18n.js 以调用自定义 servlet 而不是 otb servlet.
- 自定义 servlet 被编码为仅返回特定数据字典而不是所有字典.
这解决了我的问题.尽管我不相信这是正确的解决方案.需要一种 otb 方式来呈现这种干净.
This solved my problem. Though am not convinced as proper solution. There needs to an otb way of rendering this clean.
这篇关于我可以获得特定字典的整个 i18n 标签吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!