Tinderbox v10 Icon

locale([localeCodeStr])


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Function  [other Function type actions]

 Document  [operators of similar scope]

 Date-time  [other Date-time operators]

 Baseline

 As at baseline


Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses


locale(localeCodeStr)

locale(), allows changing of the locale used to translate dates. The same date can be written in a different format in different parts of the world. For example, in the USA a date is written 12/1/2006 to denote December 1, whereas in UK the same date is written 1/12/2006 and so on for variations around the world.

To read the current host OS' locale, call the operator with no argument:

$MyString = locale(); 

To set a locale, e.g. here for 'British English', pass the desired locale's code value as localeCodeStr;

locale("en_GB") 

Locale codes begin with a two-letter language code, followed by and underscore and a two-letter region code. These are ISO standards ISO-639 and ISO-3166 respectively. Code combinations are available for any language supported by macOS.

To read, or return to, the user's preferred locale, i.e. is derived from their Mac's OS account, use

$MyString = locale(); 

You may also save the old locale in an attribute for subsequent use. For example:

$OldLocale=locale("en_GB"); 

…do various things, and then reset the original locale…

locale($OldLocale); 

… if simple call locale() with no argument if the host OS locale had remained unchanged.

Note that changing the locale() can be fairly time-consuming, as lots of machinery must be torn down and rebuilt for each change.