Is there any universal method to detect the OS default language? (regardless what is the OS that is running the code)
import os
os.getenv('LANG')
The above code works under Linux, does it work under other OS?
Is there any universal method to detect the OS default language? (regardless what is the OS that is running the code)
import os
os.getenv('LANG')
The above code works under Linux, does it work under other OS?
You could use the getdefaultlocale function in the locale module. It returns the language code and encoding of the system default locale in a tuple:
>>> import locale
>>> locale.getdefaultlocale()
('en_GB', 'cp1252')