Skip to main content

Acquisition of language setting information

This section describes how to get language setting information from a specific spreadsheet.

function to use

Spreadsheet.getSpreadsheetLocale();

Use getSpreadsheetLocale() provided in the Spreadsheet class.

The return value is a character string based on the UTS standard.

You may need to authenticate at the first execution because you will access the spreadsheet when execution.

Sample code

/**
* Eligible spreadsheet ID
* https://docs.google.com/spreadsheets/d/〇〇〇/edit Part of the 〇〇〇
*/
const SPREAD_SHEET_ID = '_______________';

/**
* Return the language setting information of the spreadsheet
*/
const getSheetLocale = () => {
/** Target spreadsheet */
const ss = SpreadsheetApp.openById(SPREAD_SHEET_ID);

/** Language information */
const locale = ss.getSpreadsheetLocale();

console.log(locale);
return locale;
};

When executed, the language setting information of the spreadsheet is returned.

In Japan, you can get "ja-JP".