nodeRed 源码分析4- i18n NLS (national language suppor) 多国语言支持

博客迁移

不恰饭的小站

i18n NLS (national language suppor) 多国语言支持

所使用的库

  • i18next
  • https://www.i18next.com/

核心模块翻译数据 | Component | Namespace | Location| | ---- | ---- |---- | |Runtime |runtime

|runtime/locales/__lang__/runtime.json |Editor |editor
| editor-client/locales/__lang__/editor.json |Core
nodes |node-red
|nodes/nodes/core/locales/__lang__/messages.json

代码解析

默认 Lang “en-US”

使用

  • i18n._(“xxx.xxx.xxx.xxx”);
  • log._(“xxx.xxx.xxx.xxx”);

主要方法

  • i18n.init(opt ,callback); 完成初始化
  • i18next.loadNamespaces(ns, callback) // -> returns a Promise Loads additional namespaces not defined in init options.

实例 以node-red-node-rbe模块为例:

  1. 多国语言路径’d:\project\IOT_OpenSource\node-red-master\node_modules\node-red-node-rbe\locales’
  2. 多国语言信息文件 rbe.json
  3. 多国语言帮助信息 rbe.html
  4. 将模块按照规定的位置放置,即可启动i18n功能
  5. 代码中使用 RED._(“rbe.warn.nonumber”) 即可按当前语言配置输出想要的结果
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值