Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: get OS language

Tags:

python

What is a way to get current Windows (or OSX) Locale id on Python 2.x. I want to get an int (or str) which tells what language in OS is active.

Is possible without using WinAPI?

like image 453
Prog1020 Avatar asked Dec 16 '22 05:12

Prog1020


1 Answers

This is the documentation related to the locale module in Python 2.6.

To be more specific, here is an example (from the above link) of how to get your system's locale:

import locale
loc = locale.getlocale() # get current locale
locale.getdefaultlocale() # Tries to determine the default locale settings and returns them as a tuple of the form (language code, encoding); e.g, ('en_US', 'UTF-8').
like image 177
AbdulMomen عبدالمؤمن Avatar answered Dec 28 '22 18:12

AbdulMomen عبدالمؤمن