mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Updated Design: i18n (markdown)
parent
025ec7b752
commit
6d46654a33
@ -38,25 +38,27 @@ The catalog for a node-set is added under the namespace `<module>/<set>`.
|
|||||||
|
|
||||||
## Loading catalogs in the editor
|
## Loading catalogs in the editor
|
||||||
|
|
||||||
|
**All of this is subject to change - need to figure out how best for the editor to express what language it wants the catalogs in**
|
||||||
|
|
||||||
A node's localized help will automatically get included with the existing methods to retrieve the node's editor configuration.
|
A node's localized help will automatically get included with the existing methods to retrieve the node's editor configuration.
|
||||||
|
|
||||||
For message catalogs, a new api end-point is added:
|
For message catalogs, a new api end-point is added:
|
||||||
|
|
||||||
/locales/__lang__/__namespace__.json
|
/locales/__namespace__
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
/locales/en-US/node-red.json
|
/locales/node-red
|
||||||
|
|
||||||
will load the catalog for all core nodes.
|
will load the catalog for all core nodes.
|
||||||
|
|
||||||
/locales/en-US/node-red-contrib-twilio/twilio.json
|
/locales/node-red-contrib-twilio/twilio
|
||||||
|
|
||||||
will load the catalog for the `node-red-contrib-twilio/twilio` node set.
|
will load the catalog for the `node-red-contrib-twilio/twilio` node set.
|
||||||
|
|
||||||
## Using i18n for messages
|
## Using i18n for messages
|
||||||
|
|
||||||
### Core Runtime
|
### Runtime
|
||||||
|
|
||||||
var i18n = require("./path/to/i18n.js");
|
var i18n = require("./path/to/i18n.js");
|
||||||
// i18n._ is provided as a wrapper to i18next.t
|
// i18n._ is provided as a wrapper to i18next.t
|
||||||
@ -68,11 +70,17 @@ will load the catalog for the `node-red-contrib-twilio/twilio` node set.
|
|||||||
// "example.insert" : "I have a value of __myValue__"
|
// "example.insert" : "I have a value of __myValue__"
|
||||||
console.log(i18n._("example.insert",{myValue: 123});
|
console.log(i18n._("example.insert",{myValue: 123});
|
||||||
|
|
||||||
### Nodes
|
#### Nodes
|
||||||
|
|
||||||
Nodes can use `RED._()` to retrieve messages. The function they are provided is pre-scoped to the node's own namespace so they don't have to worry about providing it with each message.
|
Nodes can use `RED._()` to retrieve messages. The function they are provided is pre-scoped to the node's own namespace so they don't have to worry about providing it with each message.
|
||||||
|
|
||||||
# TODO
|
### Editor
|
||||||
|
|
||||||
|
`RED._()` is provided for core editor code.
|
||||||
|
|
||||||
|
Any html element can set a `data-i18n` attribute, as documented [here](http://i18next.com/pages/doc_jquery.html). *NB*: `$(element).i18n()` must be called after `element` is added to the DOM in order for these attributes to be parsed.
|
||||||
|
|
||||||
|
#### Nodes
|
||||||
|
|
||||||
|
As well as the `data-i18n` attribute for html elements, all node definition functions (`oneditprepare` etc) can use `this._()` to retrieve messages, pre-scoped to the node's namespace.
|
||||||
|
|
||||||
- loading a node's catalog in the editor
|
|
||||||
- how to NLS the ui components of a node
|
|
||||||
|
Loading…
Reference in New Issue
Block a user