Question on internationalisation: Can I have 1 json file for several nodes?

It is sort of possible, but not as elegant as perhaps you'd like.

A bit of terminology to help explain, apols if I'm telling you stuff you know, but for future readers of this thread....

In your package.json file, you have this:

  "node-red": {
    "version": ">=3",
    "nodes": {
      "uibuilder": "nodes/uibuilder.js",
      "uib-cache": "nodes/uib-cache.js",
      "uib-element": "nodes/uib-element/customNode.js",
      "uib-update": "nodes/uib-update/customNode.js",
      "uib-sender": "nodes/uib-sender.js",
      "uib-list": "nodes/uib-list/customNode.js"
    },

The keys of the nodes property are internally known as the node-set name. Each node-set can have its own message catalog.

There is no concept of a module-wide catalog, but you can look-up messages from any other catalog that node-red has loaded. You do that by prefixing the message identifier with the catalog name.

For example, you could put all your common messages in uibuilder.json and then any other node would be able to use RED._("node-red-contrib-uibuilder/uibuilder:the.message.identifier")

It is a bit long winded to have to fully specify the catalog as well as the message id, but that's how you do it.

1 Like