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.jsonGlobal 👉 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 pug files
By default, id is used to match with key in local's files.
+dxpFormRowInputText({ id: 'name', label: 'Name', icon: 'tag' })and you can set key in local file:
{
"name": "my perfect name",
"name-placeholder": "my perfect name" // key is automatically generated
}Alternatively, you can pass an arbitrary i18n key:
+dxpFormRowInputText({ id: 'name', label: 'Name', icon: 'tag', i18nKey: 'other_key' }){
"other_key": "my perfect name on other key",
"other_key-placeholder": "my perfect name" // key is automatically generated
}NB:
- i18n key is apply on label inner text and
titleprop. placeholderfor inputText is also considered and a new key{key}-placeholderis automatically generated
In editor HTML
⚠️ Please, consider use pug file 🙏
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.
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.