user1248569
user1248569

Reputation: 131

Language of the operating system?

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

Answers (2)

Mud
Mud

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

ShinTakezou
ShinTakezou

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

Related Questions