How to change Google Apps Script locale?
Asked Answered
G

2

10

I created a Google Apps Script on the Google account, which had the Polish language set in the settings. Executing the script was causing some Google error message about exceeding quote Gmail rateMax, which was displayed in Polish.

I shared this script with another account, where language was set to English in account settings. To my surprise, executing the script on the account where language was set to English, caused the error message to still appear in Polish.

Question: how can I change the 'locale' of the Google Apps Script? Is it even possible?

Or is the only option to create new script on the account with English locale, and copy over the code?

Guesswarp answered 30/1, 2014 at 20:58 Comment(0)
T
4

If you created the script from within a spreadsheet -- by selecting Tools --> Script Editor within the Sheets UI, then executing setSpreadsheetLocale() on the spreadsheet should apply your locale setting to the script, too.

If you created the script as a new document from Drive, then your suspicion appears to be correct -- there is no user-visible locale setting for a Script Document, so you'll have to create the script with an English-locale account.

You can refer to the official documentation for more info.

Terriss answered 4/11, 2014 at 17:59 Comment(2)
This is still the situation even though it is already 2017. There is still no way to set Locale setting for Appscript.Legibility
The instructions discussed at support.google.com/docs/answer/… do not even appear on the actual spreadsheet application.Headwater
B
0

The Google Apps Script project uses the active user locale. If you want that the error messages be shown in a different locale, change the active user language to the one that you want to use (very easy if it's your own account, very difficult if the account belongs to someone else)

Demonstration

Running the following script in a stand-along project using accounts in different languages will log:

  1. the active user locale
  2. an error message in the active user locale

 

function myFunction() {
  console.info(Session.getActiveUserLocale());
  try{
    SpreadsheetApp.getUi().alert('Hello world!');
  } catch (e){
    console.error(e.message);
  }
}

The following screen shot shows the messages logged (from top to bottom) first when the script was ran by an account using Spanish - Mexico, second using English

Spanish - Mexico

Jun 19, 2020, 3:34:07 PM    Info    es_419
Jun 19, 2020, 3:34:07 PM    Error   No se puede usar SpreadsheetApp.getUi() desde este contexto.

English

Jun 19, 2020, 3:33:18 PM    Info    en
Jun 19, 2020, 3:33:18 PM    Error   Cannot call SpreadsheetApp.getUi() from this context.
Burkett answered 19/6, 2020 at 20:44 Comment(2)
My account seems to be stuck in en_US locale even though my Windows is set to UK and my Google Account is set to UK.Karelian
@Karelian Hi. I suggest you to post a new question.Burkett

© 2022 - 2024 — McMap. All rights reserved.