Updated Design: i18n (markdown)

Nick O'Leary 2015-05-06 22:26:25 +01:00
parent 025ec7b752
commit 6d46654a33
1 changed files with 16 additions and 8 deletions

@ -38,25 +38,27 @@ The catalog for a node-set is added under the namespace `<module>/<set>`.
## 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.
For message catalogs, a new api end-point is added:
/locales/__lang__/__namespace__.json
/locales/__namespace__
For example:
/locales/en-US/node-red.json
/locales/node-red
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.
## Using i18n for messages
### Core Runtime
### Runtime
var i18n = require("./path/to/i18n.js");
// 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__"
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.
# 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