Search code examples
javascriptgoogle-apps-scriptgoogle-slides-apigoogle-slides

How do I get the language of the Slides?


In Google Sheets I can get the language of the spreadsheet by SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetLocale()

What is the equivalent way in Google Slides Script?


Solution

    • You want to retrieve the locale of Google Slides.
    • You want to achieve this using Google Apps Script.

    If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.

    Issue and workaround:

    Unfortunately, it seems that there are no built-in methods for retrieving the locate of Google Slides in Slides service. So in this case, as a workaround, how about using Slides API? When the Slides API is used, the locale can be retrieved.

    It seems that the value retrieved by Slides API is different from getSpreadsheetLocale(). In my environment, getSpreadsheetLocale() returns ja_JP. The value of locale retrieved by Slides API is ja. Please be careful this. The official document says as follows.

    locale: The locale of the presentation, as an IETF BCP 47 language tag.

    Sample script:

    When you use this script, please enable Slides API at Advanced Google services.

    var presentationId = "###";  // Please set the Slides ID.
    var locale = Slides.Presentations.get(presentationId).locale;
    Logger.log(locale)
    

    References:

    If I misunderstood your question and this was not the direction you want, I apologize.