Internationalisation (i18n)
Config files
├── src
│ ├── locales # Global locales files
│ │ ├── en-US.json
│ │ └── fr.json
│ ├── nodes
│ │ ├── my-node-1
│ │ │ ├── locales # Node specific locales files
│ │ │ │ ├── en-US.json
│ │ │ │ └── fr.json
Global (available in all nodes)
Mandatory ⚠️
Place your global config files in the src/locales
directory. Files must be named with the language code of Node-RED. For example, en-US.json
.
For example, add a file src/locales/en-US.json
with the following content:
{
"hello": "Hello"
}
This will make the hello
key available in all nodes.
Scoped (available in a specific node)
Mandatory ⚠️
Place your global config files in the src/nodes/my_node/locales
directory. Files must be named with the language code of Node-RED. For example, en-US.json
.
For example, add a file src/nodes/my_node/locales/en-US.json
with the following content:
{
"foo": "Foo"
}
This will make the foo
key available only in the my_node
node.
Usage
In editor HTML
You can follow official doc but with one important difference:
You don't need to prefix the key with the node name. Just use the key directly.
For example. In the file src/nodes/my_node/editor/index.html
:
✅ Good
<span data-i18n="foo"></span>
❌ Bad
<span data-i18n="my_node.foo"></span>
WARNING
foo
must be defined in the global or scoped node config files.
🚧 Some work is in progress to make its behaviour as an option.
In scripts
For now, you can use the RED._
function to get the translation from Node-RED official doc.
So, you must include node name in the key.
🚧 Some work is in progress to make it easier to use, like the HTML part.