For example: http://www.doughellmann.com/PyMOTW/gettext/.
However, if you are following these tutorials on Windows, gettext will be failed to load the .mo file even you correctly specified the 'localedir' parameter.
For example:
import gettextt = gettext.translation('cn', 'C:\locale', 'en_US', fallback=True)
will fail to load "cn.mo" from "C:\local\en_US\LC_MESSAGES".[1]
The reason is that standard gettext module in Python does not use startdard language settings from Windows settings, but instead relies on presence one of the environment variables:
Therefore, you must add one of above environment variables into your windows settings. Just add:
LANG=en_US
into your system global environment variable. Then gettext will be able to load cn.mo file from "C:\local\en_US\LC_MESSAGES".
The reason is that standard gettext module in Python does not use startdard language settings from Windows settings, but instead relies on presence one of the environment variables:
LANGUAGE
, LC_MESSAGES
, LC_ALL
or LANG
.Therefore, you must add one of above environment variables into your windows settings. Just add:
LANG=en_US
into your system global environment variable. Then gettext will be able to load cn.mo file from "C:\local\en_US\LC_MESSAGES".
Thank you so much! This worked perfectly.
ReplyDelete