Issue with Code and Locale

Hi there, I need to format dates in my locale, Italian.

This code is supposed to work:

var options = { weekday: 'long'};
giorno_estratto = date_date.toLocaleDateString('it-IT', options);

but the returned string is still in English instead than in Italian.

I’ve tried switching to German and the string is still returned in English.

This happens on both the Voiceflow test env and on Amazon console.

If it matters this happens on both a project specified to support Italian only and another one supporting both Italian and English.

Hi Sonicaaaa,

If your just trying to get the date format for that locale, try:

var dateTimeNow = new Date;
var options = { weekday: ‘long’};
giorno_estratto = dateTimeNow.toLocaleDateString(‘it-IT’, options); // date_date. is not a valid date object, unless you defined it above that code. But the above works, brings back venerdì

I added in some other options as well in this one, in case you are playing around with it. This would be the correct time in Rome.

var dateTimeNow = new Date;
var options = { weekday: ‘long’, month: ‘long’, year: ‘numeric’, day: ‘numeric’ , timeZoneName: ‘short’, timeZone: ‘Europe/Rome’ } ;
giorno_estratto = dateTimeNow.toLocaleDateString(‘it-IT’, options); // Brings back sabato 1 febbraio 2020, CET

Thank you for trying this and indeed your sample output looks correct.

But for whatever reason beyond my understanding I keep getting back the answer in English. On both VoiceFlow and Amazon console.

I’ve even tried to create a fresh project to to exclude any other possibility, but I get the same result.

Actually I’ve noticed that using your second example I have an even more surprising output, with no long month or long weekday:

Screenshot from 2020-02-01 16-58-15

Is there any other out of sight settings that could justify this behavior, considering that I’m running the same exact code that you do?

To provide more debug information:

If I run this code:

const locales1 = ['it-IT', 'en-US', 'en-UK', 'de-DE', 'fr-FR'];
const options1 = { localeMatcher: 'lookup' };
giorno_estratto = Intl.DateTimeFormat.supportedLocalesOf(locales1, options1);
console.log("Result: " + giorno_estratto);

I get back only:

Screenshot from 2020-02-01 17-35-54

Is this a limitation of my free tier?

Hi Sonicaaaa,
I am not getting back the correct language locales in VF either. This seems(or could be) to be a Node.js issue.
By default “–with-intl=small-icu” is used in the node build and that only has US locale built in. VF would have to use intl=full-icu or --with-intl=system-icu or it looks like they could add this package as well

But this would be for the voice flow team. If that is the issue of course.

1 Like

thanks again for your tests.

My hypothesis right now is that the Voiceflow backend instance I’m connecting to is different than yours, either for version or configuration.

I hope to get some official answer here since although I can map week days from English to Italian, it would be annoying to code basing logic on a logically wrong behavior.