[Django]-Chinese django translations not working

9👍

✅

For those of you having the same issue, the solution I found is to create the locale folder with an underscore and a capital H.

So it would look like:

django-admin makemessages -l zh_Hans

The reason is that the Django documentation states:

In all cases the name of the directory containing the translation is
expected to be named using locale name notation. E.g. de, pt_BR,
es_AR, etc.

and in another part of the documentation says:

A locale name, either a language specification of the form ll or a
combined language and country specification of the form ll_CC.
Examples: it, de_AT, es, pt_BR. The language part is always in lower
case and the country part in upper case. The separator is an
underscore.

0👍

Is your chinesse locale directory named ‘zh_hans’ instead of ‘zh-hans’? I believe the directory must have underscore instead of dash.

0👍

This issue indeed confused me a lot!
Here’s a short summary base on ALUW’s answer:

# in settings.py, use lower-case language code, The separator is a dash.
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'), )
LANGUAGES = (
    ('en', _('English')),
    #Simplified Chinese
    ('zh-hans', _('Simplified Chinese')),
)
# while when making and compiling message file, use local name.
# The language part is always in lower case and the country part in upper case. 
# The separator is an underscore.

./manage.py makemessages -l zh_Hans

Leave a comment