Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

locale - how to add new languages into Django? My language "Uyghur" or "Uighur" is not supported in Django

how to add new languages into Django? My language "Uyghur" or "Uighur" is not supported in Django.

Can I add new language locale file in my project and use it? for example: zh_UG

this language is not supported in Django.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add a non available language to your Django app

ISO language code of Uighur ?????? ???? is 'ug'.

In your settings.py:

from django.conf import global_settings

gettext_noop = lambda s: s

LANGUAGES = (
       ('ug', gettext_noop('Uighur')),
)

EXTRA_LANG_INFO = {
    'ug': {
        'bidi': True, # right-to-left
        'code': 'ug',
        'name': 'Uighur',
        'name_local': u'u0626u06C7u064Au063Au06C7u0631 u062Au0649u0644u0649', #unicode codepoints here
    },
}

# Add custom languages not provided by Django
import django.conf.locale
LANG_INFO = dict(django.conf.locale.LANG_INFO, **EXTRA_LANG_INFO)
django.conf.locale.LANG_INFO = LANG_INFO

# Languages using BiDi (right-to-left) layout
LANGUAGES_BIDI = global_settings.LANGUAGES_BIDI + ["ug"]

And:

manage.py makemessages -l ug
manage.py compilemessages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...