os.setlocale

Sets the current locale to the supplied locale

Prototype

name = os.setlocale (locale, category)

Description

Sets the current locale to the supplied locale. Category, which is optional, is a string which is one of: Returns the name of the new locale, or nil if invalid.

print (os.setlocale ("en", "collate")) --> English_United States.1252
Hint: I found that in Australia, the default in Lua was to use the USA time format (MM/DD/YY) rather than the local format (DD/MM/YY) when displaying dates with os.date. This line seemed to fix that:

print (os.setlocale ("", "time")) --> English_Australia.1252
According to the help file "If locale points to an empty string, the locale is the implementation-defined native environment.". Thus the empty locale string seemed take the country default.

Lua functions

Topics