Question

I need to format a date in GAS, as month/year, with month as a word, in italian.

I used the Language.App.translate, as the Utilities.formatDate formats the month in English language. The code fragment is the following:

  var dteng = Utilities.formatDate(dt, "CET", "MMMM/yyyy");
  dttran = LanguageApp.translate(dteng, 'en', 'it');

When I execute the script with my user, it works fine, and the translation is done. When I execute it as a different user (the one who is actually using the script), the translation doesn't happen.

The execution transcript reports:

LanguageApp.translate([January/2007, en, it])

but the result is the same, untranslated string.

All the remaining part of the script executes without problems.

Any hint? Should I open an issue?

tks

Massimo

Was it helpful?

Solution

In my case the behavior of:

function getTranslate() {
  var dteng = Utilities.formatDate(new Date(2007, 0, 1), 'CET', 'MMMM/yyyy');
  var dttran = LanguageApp.translate(dteng, 'en', 'it');
  /*var dttran = LanguageApp.translate(dteng, 'en', 'es'); // `Enero/2007` <- works as expected.*/
  Logger.log(dttran); // January/2007
}

is equal in all cases, for any user, always returns January/2007.

Apparently certain characters are not interpreted correctly, with formats like: 'MMMM/yyyy', 'MMMM.yyyy' or 'MMMM_yyyy' not perform the appropriate translation.

With other formats (e.g. 'MMMM-yyyy'), works as expected.

UPDATE

Using Google Translate from the Web:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top