N8n localization - how to implement to get accepted?

I’m looking and considering implementation of n8n localization mechanism - what would be the implementation, that n8n would accept in the mainstream?

Here is how we did it in our fork of n8n:

Frontend

For frontend localization we use vue-gettext library
and easygettext which extract strings as a frontend POT file.
It worked out pretty well. Except for the localization of text blocks interleaved with html tags
(example).

Backend

We skipped localizing backend strings completely. We didn’t want to diverge too much from upstream branch.
Luckily, packages/cli does not contain too many strings that are visible to users.

Nodes and Credentials

For localizing node type and credential properties we decided not to annotate string values
in source code, again, to minimize changes from upstream. Instead, we came up with an idea
to translate them manually when requested by the frontend. We had to do text extraction manually
and for this, we wrote a tool that loads all node type and credential classes from a directory
and recursively walks through properties tree extracting string values into a POT file.
This POT file is then stored into dist folder to make it available when the package is installed.
We also store the path to POT file in package.json. This tool is configured as a git pre-commit hook
to keep POT file always relevant. This same mechanism is applied to all our own non-core node-type
repositories.

Production Build

We created a separate repository to define exact versions of n8n core packages including our
own packages that gets into final production docker image. In this repo we also configured a script
that collects all POT files from n8n-nodes-base and other node-type packages and merges them
into a single backend POT file.

We have Weblate configured that derives imports string from both POT files
and periodically commits back translated strings into corresponding PO files for the japanese locale.

When building docker image, PO files are converted into JSON files and sealed into the image.

1 Like