I want to add a piece to manage locally i18n translations. The use case is basically handling flows for users with languages preferences: we can react sending mail/sms/messages in the user’s preferred language.
Alternatives
Using plain store is a lot of get/set, and then write custom script to handle interpolation. Not perfect as pluralization won’t work nicely.
Using an external service: why not, but overkill to use an external service to handle just a few lines of translations.
Solution proposed
A I18n Store would uses i18next (already installed) and expose three actions :
Set configuration (project wide): allow upload of .yml or .json files, and i18n settings like interpolations delimiters and fallback language
Translate: give a path, interpolation variables and a locale. Optionally ask to return objects to translate many strings at once
Settings: get available locales, and previously set configuration
This way we can:
loop over available locales if we talk to an external multi-lingual service that handles prefs.
take translations string and interpolate with count variables that will handle pluralization
use interpolation delimiter for the files you already have in whatever stack you use.
The implementation would use context.store with a Project Scope, in order to set translation in a flow and use it as much as you want.
Current state
I developed a first version of the piece here:
https://github.com/octree-gva/activepieces/tree/packages/octree/packages/pieces/community/i18n-store
And published on NPM here:
https://www.npmjs.com/package/@octree/piece-i18n-store
I need feedback from the community if this piece is worth a PR in active pieces, :)
And if some people can try it and test, that would help the piece grow to a v1 faster
Thanks a lot, and have a great day!


Please authenticate to join the conversation.
In Review
🧩 Pieces
30 days ago

hfroger
Get notified by email when there are changes.
In Review
🧩 Pieces
30 days ago

hfroger
Get notified by email when there are changes.