6

Ok so I'm writing an international Django app, And the docs for doing localization are great except I can't seem to find a complete list of the supported languages anywhere. Where are they? What I really want to do is use the list to populate choices on a model, so if there is a way to get this programmatically that would be best.

Thanks!

Stefano
  • 18,083
  • 13
  • 64
  • 79
UserZer0
  • 1,441
  • 2
  • 14
  • 27
  • Are you looking for this list? http://en.wikipedia.org/wiki/Locale If so, please update your question to get rid of ALL UPPER CASE LETTERS. THEY MAKE YOUR QUESTION LOOK STUPID. – S.Lott Feb 10 '11 at 01:16
  • No that would be a definition of what a Locale is. I was looking for a list that has the locales Django supports and the code for each of them. – UserZer0 Feb 10 '11 at 02:31
  • also see http://stackoverflow.com/questions/3201018/django-language-codes – Stefano Sep 20 '12 at 10:22

4 Answers4

6

Straight from the source. All languages Django (trunk) offers translations for.

http://code.djangoproject.com/browser/django/trunk/django/conf/locale

Reiner Gerecke
  • 11,936
  • 1
  • 49
  • 41
3

Cleaning up the pieces of answers:

from django.conf.global_settings import LANGUAGES

class MyModel(models.Model)
    my_field = CharField(max_length=7, choices=LANGUAGES)

and you can see the code directly: global_settings and locale/__init__.py

For more complete instructions on how to build a more extensive list, check out the W3C Language Tag Page

Stefano
  • 18,083
  • 13
  • 64
  • 79
3

This may be what you're looking for:

http://code.djangoproject.com/browser/django/tags/releases/1.2.4/django/conf/locale

RJ Regenold
  • 1,748
  • 13
  • 17
  • 2
    I think this is close to what you're wanting: http://code.djangoproject.com/browser/django/tags/releases/1.2.4/django/conf/global_settings.py#L43 – RJ Regenold Feb 10 '11 at 02:45
  • 1
    Hi RJ, sorry for the downvote, but I do so with the good intentions of keeping the content here on SO fresh. The link you refer to is dead, so its sorta useless =/ – mkoistinen Mar 31 '13 at 20:56
  • @mkoistinen you could provide an up-to-date link yourself, you know. The guy can hardly be held accountable for bit rot. – nadavwr Apr 26 '13 at 13:38
  • 2
    @nadavwr True, this is why I made sure to let him know that it wasn't personal. The fact remains, as time continues to march on, this is still the top-voted answer for this question, and it is 100% useless today. If others downvoted responses that are currently useless and upvoted those that are more useful today, then SO will become a more useful place for everyone, right? Also, since linkrot is a fact of life for everyone, perhaps the utility of this answer shouldn't rely 100% on a single link? I remain justified in my downvote. – mkoistinen Apr 26 '13 at 13:55
0

Instructions within django's settings file itself.

http://www.i18nguy.com/unicode/language-identifiers.html

Llanilek
  • 3,386
  • 5
  • 39
  • 65