Jsreport 的多语言能力

Multiple languages capability of Jsreport

我想知道jsreport是否有将报告翻译成其他语言的能力。例如,在我发送到 jsreport 以呈现的数据中有选择的语言(德语、意大利语等),我可以做任何事情(在模板中设置、调用外部服务等)将一些关键文本翻译成这些语言。

不过这个问题是关于通用jsreport目前支持多国语言

这是目前 (jsreport@1.x) 使用资源扩展实现的。

http://jsreport.net/learn/resources

Resources extension lets you attach multiple JSON data objects to the report template and later conveniently access them using templating engines or in custom scripts. This can be useful to add a general configuration to the template or mainly localize the template...

利用资源扩展实现本地化的主要途径:

  1. 将每种语言的资源(json 数据项)上传到 jsreport studio 并以语言前缀命名它 - en-myresourcede-myresource
  2. 将资源部分内的数据项与报告模板相关联
  3. 使用 $localizedResource 达到模板引擎中的本地化值,例如 {{:$localizedResource.invoice.title}}
  4. 指定要在 API 请求中使用的特定语言:{ template: {...}, options: { language: "de" } }

示例:https://playground.jsreport.net/studio/workspace/VkLWfMyMb/7