Language correct date&time display in python plugins via setlocale() function

helour

Registered
Messages
9
Hi,

I have made shell script which enables installing locale files which are needed for correct languge:

string comparison (LC_COLLATE)
lower & upper string conversion, isupper & islower testing (LC_CTYPE)
monetary formatting (LC_MONETARY)
decimal separator (LC_NUMERIC)
date & time formating (LC_TIME)

After installing locale files for your language you can use all "language critical" functions in your python scripts (converters, renderers, plugins, etc.)

All you need is to run locale_files.sh script, then you have to set proper language locale argument in the setlocale() function in some python files as you can see below:
PHP:
def __init__(self, type):

try:
    setlocale(LC_ALL, language.getLanguage())
except:
    pass

For example, you can see my small modification of the ClockToText.py converter which enables to display date/time string according to user language localization.
 
Top