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?

2 Answers 2

5

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.

2
  • 2
    This is still the situation even though it is already 2017. There is still no way to set Locale setting for Appscript.
    – VLBaindoor
    Jan 12, 2017 at 6:16
  • The instructions discussed at support.google.com/docs/answer/… do not even appear on the actual spreadsheet application. Oct 29, 2018 at 12:05
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.
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.
    – PhilHibbs
    Jan 6, 2022 at 14:46
  • @PhilHibbs Hi. I suggest you to post a new question.
    – Wicket
    Jan 6, 2022 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.