“Power Automate gives me always the day and month name in English, is there some way how to convert the date to my local language?”
Power Automate uses by default the UTC time zone and English names for days and months. It’s not a big deal regarding the time zone as there’re action and expressions to convert the time. But with the names it gets more complicated. There’s no action nor expression that would translate it directly. If you need the days and/or month names in your local language, you’ll need either an external service or your own solution.
Use Microsoft Translator
The easier solution is to use Microsoft translator. There’s an action ‘Microsoft Translator V2‘ that allows you to connect to the Microsoft Translator and translate any text (including dates).
You can create a connection even if you don’t have any subscription, just type in any connection name and click on ‘Create’.
It’ll create a free connection to the service. Enter the date you want to translate in the action and you’ll get the translated result. Make sure to format the date before you translate it! The result will be a translated text and it won’t be possible to change the date format.
Note: the limitation of the free connection is 100 translation requests per minute and 55,000 characters per day. If you need more translation than that, you’ll need either a paid subscription or the translation solution below.
Build your own translator
The other solution is to build your own translator. You’ll need 2 mapping tables between the English names and your local names – for months and for days. Initialise 2 object variables – one for months:
{
"January": "Leden",
"February": "Únor",
"March": "Březen",
"April": "Duben",
"May": "Květen",
"June": "Červen",
"July": "Červenec",
"August": "Srpen",
"September": "Září",
"October": "Říjen",
"November": "Listopad",
"December": "Prosinec"
}
and one for days:
{
"Monday": "Pondělí",
"Tuesday": "Úterý",
"Wednesday": "Středa",
"Thursday": "Čtvrtek",
"Friday": "Pátek",
"Saturday": "Sobota",
"Sunday": "Neděle"
}
Once you create them, you can easily pick the local name based on the English one using an expression. Since these are object variables, extract the values as from any other JSON.
variables('var_month')?[<English name>]
The date format that will give you the month is ‘MMMM’ and full day name is ‘dddd’. Use this knowledge to get the <English name> part, e.g.
variables('var_month')?[utcNow('MMMM')] - get the month name
variables('var_day')?[utcNow('dddd')] - get the day name
The full expression for a translated date can then look like:
concat(variables('var_day')?[utcNow('dddd')], ' ', utcNow('dd'), '. ', variables('var_month')?[utcNow('MMMM')], ' ', utcNow('yyyy'))
Summary
As you can see, you’ve got at least two options how to translate a date to a local language in Power Automate. The first one, using Microsoft Translator is the easier one. You send a string to the translator, and it’ll translate it. The connection limitations are quite generous and might be sufficient for many use cases.
The second option gives you more freedom. There’s no limitation, and maybe more importantly, you have full control over the translated name. This is very valuable if you need to inflect the day/month name to be grammatically correct. And that might be the reason why I prefer the second solution in this situation.
What an elegant solution with Microsoft Translator. Thank you very much
Hi, great job with this! 🙂
I create first flow and I want translate months from english to polish. I found your scripts, but they have inside date utcNow(). I would like to change date to previous month in code using action “Substract from time”. It`s possible? I keep getting syntax error and don’t know how to do it anymore.
Hi Pawel, it is possible for sure. You only need to use the function addToTime with a negative index to subtract, like below:
addToTime(utcNow(),-1,’month’, ‘MMMM’)
But i don’t know where i should be putting this code 🙂
If I use:
concat(variables(‘var_day’)?[addToTime(utcNow(),-1,’month’, ‘MMMM’)], ‘LALALA’)
i get error message “expression is invalid”
Hello Pawel,
you’ll have to replace all the utcNow(…) expressions with the expression. Instead of:
concat(variables(‘var_day’)?[utcNow(‘dddd’)], ‘ ‘, utcNow(‘dd’), ‘. ‘, variables(‘var_month’)?[utcNow(‘MMMM’)], ‘ ‘, utcNow(‘yyyy’))
it’d look like:
concat(variables(‘var_day’)?[addToTime(utcNow(),-1,’month’, ‘dddd’)], ‘ ‘, addToTime(utcNow(),-1,’month’, ‘dd’), ‘. ‘, variables(‘var_month’)?[addToTime(utcNow(),-1,’month’, ‘MMMM’)], ‘ ‘, addToTime(utcNow(),-1,’month’, ‘yyyy’))
How to get Year in Cardinal eg:
2024 -> two thousand and twenty four