Django internationalization language codes [closed]
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:
Previous answers mention only getting LANGUAGE
from settings.py, hovewer there is a big chance that this variable will be overwritten. So, you can get the full list from django.conf.global_settings.LANGUAGES
from django.db import modelsfrom django.conf.global_settings import LANGUAGESclass ModelWithLanguage(models.Model): language = models.CharField(max_length=7, choices=LANGUAGES)