From 110b748385c2fc1adf29115c0cd543831bbbe92b Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 8 May 2015 16:42:12 +0100 Subject: [PATCH] Updated Design: i18n (markdown) --- Design:-i18n.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Design:-i18n.md b/Design:-i18n.md index 9ac0ead..96d84aa 100644 --- a/Design:-i18n.md +++ b/Design:-i18n.md @@ -60,19 +60,23 @@ will load the catalog for the `node-red-contrib-twilio/twilio` node set. ### Runtime - var i18n = require("./path/to/i18n.js"); - // i18n._ is provided as a wrapper to i18next.t +A new module is provided, `red/i18n` as a wrapper to the external `i18next` module. In the majority of cases within the runtime, the messages are used within calls to `log.log/warn/...`. As a convenience, `log._()` is provided as a wrapper to the `i18next.t` function. + + var log = require("red/log.js"); + // log._ is provided as a wrapper to i18next.t // Retrieve the value of the message `runtime.version` - console.log(i18n._("runtime.version")); + log.info(log._("runtime.version")); // Retrieve the value of the message `example.insert" with a named insert // "example.insert" : "I have a value of __myValue__" - console.log(i18n._("example.insert",{myValue: 123}); + log.info(log._("example.insert",{myValue: 123}); + +See the documentation for `i18next.t` for more examples around plural handling etc. #### 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 are passed a reference to the `RED` object as part of the standard node module interface. Within that object, `RED._()` can be used 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. ### Editor