The toLocaleUpperCase() method is a String method in Apps Script that returns a string converted to uppercase based on the locale of the user’s system. This means that it converts the string to uppercase letters while considering the language and region of the user. The method is useful when dealing with internationalization and localization.
For example, if you have a string “école” in French, using the toLocaleUpperCase() method will convert it to “ÉCOLE” as it is the uppercase form in French. Similarly, if you have a string “straße” in German, using the method will convert it to “STRASSE” as it is the uppercase form in German.
Here are two examples of using the toLocaleUpperCase() method:
var name = "Joaquín"; var nameUpper = name.toLocaleUpperCase('es'); Logger.log(nameUpper); // JOAQUÍN
In this example, the method is used to convert the name “Joaquín” to uppercase while considering the Spanish language and region.
var city = "München"; var cityUpper = city.toLocaleUpperCase('de'); Logger.log(cityUpper); // MÜNCHEN
In this example, the method is used to convert the city name “München” to uppercase while considering the German language and region.
In both examples, the toLocaleUpperCase() method is used to correctly convert the strings to uppercase letters based on the language and region.