os.setlocale
Lua function

os.setlocale

Summary

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:


  • "all" (the default)
  • "collate"
  • "ctype"
  • "monetory"
  • "numeric"
  • "time"


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.



See Also ...

Topics

DOC_lua_base Lua base functions
DOC_lua_bc Lua bc (big number) functions
DOC_lua_bit Lua bit manipulation functions
DOC_lua_coroutines Lua coroutine functions
DOC_lua_debug Lua debug functions
DOC_lua_io Lua io functions
DOC_lua_math Lua math functions
DOC_lua_os Lua os functions
DOC_lua_package Lua package functions
DOC_lua_rex Lua PCRE regular expression functions
DOC_lua Lua script extensions
DOC_lua_string Lua string functions
DOC_lua_tables Lua table functions
DOC_lua_utils Lua utilities
DOC_scripting Scripting

Lua functions

LUA_os.clock os.clock (Amount of CPU time used)
LUA_os.date os.date (Formats a date/time string)
LUA_os.difftime os.difftime (Calculates a time difference in seconds)
LUA_os.execute os.execute (Executes an operating system command)
LUA_os.exit os.exit (Attempts to terminate the process)
LUA_os.getenv os.getenv (Returns an operating system environment variable)
LUA_os.remove os.remove (Deletes a file)
LUA_os.rename os.rename (Renames a file)
LUA_os.time os.time (Returns the current time or calculates the time in seconds from a table)
LUA_os.tmpname os.tmpname (Returns a name for a temporary file)

(Help topic: lua=os.setlocale)

DOC_contents Documentation contents page