Django internationalization language codes

Hulk picture Hulk · Jul 8, 2010 · Viewed 40.9k times · Source

Where can I find list of languages and language_code like this.

(Swedish,sv)
(English,en)

Answer

Thomas picture Thomas · Jul 8, 2010

If you want something you can use from within django, try:

from django.conf import settings

this will be in the format above, making it perfect for assignment in one of your models choices= fields. (i.e. user_language = models.CharField(max_length=7, choices=settings.LANGUAGES))

LANGUAGES = (
    ('ar', gettext_noop('Arabic')),
    ('bg', gettext_noop('Bulgarian')),
    ('bn', gettext_noop('Bengali')),
    etc....
    )

Note about using settings:

Note that django.conf.settings isn’t a module