Is there a way to format date to display in other languages?

I been trying to display dates in Spanish. I can change the format with FORMAT_DATETIME_LOCAL so the order is “dd/mmm/yyyy”, but months display in English (ie: January instead of enero).
Is there a way to do it?

1 Like

I tried to think about this, but I don’t think we have a way to do this out of the box :thinking: I would just do a replace over the month names just to work around this, probably with a page/app variable that has the English/Spanish names for months and then in a formula mapping the Spanish names over the English ones.

Thanks Mevi.

As I understand, AppGyver uses Moment.js. If so:

  • Will it be possible to call moment.js functions from a javascript flow function without loading the library?
  • Or from a Html direct call?

Well, this goes into the “secret Composer hacks that aren’t officially supported but you can use if you know they are there” section. Use with caution. You can use Moment.js in the JavaScript function box via self.moment(), but there is no documentation or anything surrounding this.

Disclaimer: this is not an officially supported feature, and could stop working at some point in the future without any warning. Hopefully this helps!

Thanks. I will give it a try.

Is it now possible to do this? I want the day and month of the date written in german. So Tuesday, 09. March 2021 should be Dienstag, 09. März 2021.
I get the Date data from an date picker flow function and set it to an page variable to show it.

I have no idea how to translate with page/app variable.

There’s no additional support, so using Moment.js in the JavaScript function box as described above is still the best way to go.

ok, but i don’t have any coding skills. so it’s not available for me.

In that case, you could create a frankenstein monster of a formula that would do this for you, something like

REPLACE_ONE(REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.YOUR_DATE_HERE, "dddd, DD. MMMM YYYY"),"Monday","Montag"),"January","Januari")

etc with as many REPLACE_ONEs as you need.

thanks. i walso thought about sth like this. i will try.

1 Like

Yes, it works.
I used this quite long formula, (and it’s only changing the english name of the month to the german one… The days aren’t included, because i don’t needed it. If anyone want to rebuild sth. like this and months that are same written in german and english i also didn’t replaced, because it’s unneccassary)
IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "January", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "January", "Januar"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "February", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "February", "Februar"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "March", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "March", "März"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "May", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "May", "Mai"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "June", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "June", "Juni"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "July", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "July", "Juli"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "October", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "October", "Oktober"), IF(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM") == "December", REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY"), "December", "Dezember"), FORMAT_DATETIME_LOCAL(pageVars.current_date, "MMMM YYYY")))))))))

1 Like

Hi! Just to let you know, since the month names are unique and you’ll only have one of them in the text snippet, you could just skip the IFs and do all of the REPLACE_ONE in a row. Eleven of them won’t find anything to replace, but that’s ok :slight_smile:

Mevi, I don’t get what you explained. I added the other months but removing the IF function gives me errors. Ofcourse it’s only optimizing because the code from Friendly works. What I have:

IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “January”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “January”, “Januari”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “February”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “February”, “Februari”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “March”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “March”, “Maart”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “April”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “April”, “April”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “May”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “May”, “Mei”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “June”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “June”, “Juni”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “July”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “July”, “Juli”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “August”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “August”, “August”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “September”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “September”, “September”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “October”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “October”, “Oktober”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “November”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “November”, “November”), IF(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM”) == “December”,&& REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “December”, “December”), FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”)))))))))))))

What I mean is like REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “January”, “Januari”), "February", Februari"), "March", Maart") etc. :blush: (and if you’re not going to change April to anything, or August or November or December, just skip adding those months.)

Thanks! That works fine. I wanted to add the other months so I can share it to others overhere. The months are the same in Dutch but maybe not in other languages.

(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(REPLACE_ONE(FORMAT_DATETIME_LOCAL(pageVars.weekdays[0].day_date, “MMMM YYYY”), “January”, “Januari”), “February”, “Februari”), “March”, “Maart”), “April”, “April”), “May”, “Mei”), “June”, “Juni”), “July”, “Juli”), “August”, “Augustus”), “September”, “September”), “October”, “Oktober”), “November”, “November”), “December”, “December”))

1 Like