diff --git a/Design:-i18n.md b/Design:-i18n.md index 8b30bbf..9ac0ead 100644 --- a/Design:-i18n.md +++ b/Design:-i18n.md @@ -38,25 +38,27 @@ The catalog for a node-set is added under the namespace `/`. ## 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