How can I get localized language name by specified locale code in python?
For example:
>> get_language_name('ja')
>> ('Japanese', u'日本語')
The getLanguage() method of Locale class in Java is used to get language code for the specified locale. This will either be an empty string or a lowercase ISO 639 code. Parameters: This method does not take any parameters.
Locale is a lightweight object that contains only a few important members: A language code. An optional country or region code. An optional variant code.
They are independent of your language. Setting a thread's locale or changing your system locale will change how numbers, dates, and times are displayed for controls created on that thread or running on your system, respectively. A language, on the other hand, is what we speak, read, and write.
In computing, a locale is a set of parameters that defines the user's language, region and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language code and a country/region code.
The Babel package can help:
>>> from babel import Locale
>>> locale = Locale('ja', 'JP')
>>> print locale.display_name
日本語 (日本)
There is also PyICU, a Python wrapper for the ICU library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With