Multilingual flows

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Locked
User avatar
kintrupf
Posts: 257
Joined: 10 Sep 2013 08:59

Multilingual flows

Post by kintrupf » 20 Feb 2015 13:19

While I like to have the notifications and toasts of my flows in English, my girlfriend likes to have them in German. So if I want to share a flow with her I have to translate each text. Next time, when I change something in that flow (even no-text items), I have to translate everything again after exporting the flow.

My first approach to solve this problem was to read all texts of a flow group from a text file into a global Map variable. Depending on another global variable the initialization flow would either read a German or an English text file. So instead of using the literal text I could use something like {getMapValue(global_translate, 'key')} to get a text. While this is a little bit ugly to type it worked, at least for simple texts.

The problem is the replacement of "inline" variables. If the original text was 'Connected to WiFi {ssid}' the variable {ssid} was not replaced with the contents of the variable :(
To solve this problem I tried various and ever more complex combinations of eval and {}, but to no avail. Either I got {error} or the variable was not replaced. Of course I could use a script action to prepare the texts for a following notification action, but I think this is a bit of an overkill, especially if a group of flows has a lot of text with variables.

So, instead of using literal texts, something like a magic getText(String key) function would be great. It would return a previously added string AND replace all variables before the text is returned. Adding strings would be done with a function addText(String key, String text) in some initialization flow, depending on the desired language.

Locked