当前位置: 动力学知识库 > 问答 > 编程问答 >

django - LANGUAGE_CODE with dashes does not work: "es-mx, es-es, es-ar" but "es" does

问题描述:

in settings.py LANGUAGE_CODE = 'es-mx' or LANGUAGE_CODE = 'es-ar'

does not work, but LANGUAGE_CODE = 'es' or LANGUAGE_CODE = 'mk' works OK when rendering the templates, I18N is active en the project settings and this is how .mo and .po looks like:

and this is the i18n context processor information:

{'LANGUAGES': (('ar', 'Arabic'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('bn', 'Bengali'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en', 'English'), ('en-gb', 'British English'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy-nl', 'Frisian'), ('ga', 'Irish'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hu', 'Hungarian'), ('id', 'Indonesian'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('nl', 'Dutch'), ('no', 'Norwegian'), ('nb', 'Norwegian Bokmal'), ('nn', 'Norwegian Nynorsk'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-cn', 'Simplified Chinese'), ('zh-tw', 'Traditional Chinese')), 'LANGUAGE_BIDI': False, 'LANGUAGE_CODE': 'es-ar'}

According django-i18n-docs "es-mx" and "es-ar" are standard lang format.

Am I missing something here? thanks in advace.

网友答案:

I looked in the django repository how the framework is handling the locale forder structure and I found the solution (see the folders name):

Thanks for viewing.

网友答案:

The documentation linked in the settings.py file for django 1.3.1 redirect to : http://www.i18nguy.com/unicode/language-identifiers.html

Maybe try to use es-AR

I had the same problem for fr-FR.

Hope it helps you.

分享给朋友:
您可能感兴趣的文章:
随机阅读: