Reputation: 131
Is there a way to get the language of the running operating system? I would like to be able to change the language of the program when it starts.
Upvotes: 1
Views: 473
Reputation: 29021
That's platform specific and beyond the cope of Lua's standard library. In some cases you may be able to figure it out from getenv
or something, but you can't rely on that in a cross platform way.
You could write a little extension module that you port to the various platforms you need to support which gives you that info for a particular operating system.
Upvotes: 1
Reputation: 9681
Maybe
print(os.setlocale(nil));
can give you the needed information, though you likely need to parse it a bit. Or you could access the proper env var, e.g.
print(os.getenv("LANG"));
gives en_GB.utf8 on my system, so you can deduce my system "talks" english.
Upvotes: 0