This always confuses me - the language code is always lower case according to the docs. Which is specified in the settings - language codes or locales? I've always assumed the former.
locale nameA locale name, either a language specification of the form ll or a combined language and country specification of the form ll_CC. Examples: it, de_AT, es, pt_BR. The language part is always in lower case and the country part in upper case. The separator is an underscore.language codeRepresents the name of a language. Browsers send the names of the languages they accept in the Accept-Language HTTP header using this format. Examples: it, de-at, es, pt-br. Both the language and the country parts are in lower case. The separator is a dash. On Friday, 20 June 2014 08:47:13 UTC-4, Vernon D. Cole wrote: > > (*cough*) > Excuse me, everyone, but many of the locale names mentioned in this > discussion have been invalid. > > https://docs.djangoproject.com/en/1.6/topics/i18n/#term-locale-name says: > >> locale nameA locale name, either a language specification of the form ll >> or a combined language and country specification of the form ll_CC. >> Examples: it, de_AT, es, pt_BR. The language part is always in lower >> case and the country part in upper case. The separator is an underscore. > > > so 'en-gb' should not be recognized. > 'en_GB' ought to be. > > > On Thursday, June 19, 2014 3:18:32 PM UTC+1, Stodge wrote: >> >> My problem seems to be this: >> >> * run custom management command >> * activate language from settings, which is "en-gb" >> * dynamically import module for a Django app and invoke custom bootstrap >> function >> * calling get_language() in bootstrap function returns "en-gb" >> * bootstrap function calls loaddata management command (using >> management.call_command) >> * data created in DB, which triggers a post_save signal >> * get_language() in post_save signal always returns "en-us" >> >> >> >> >> On Wednesday, 18 June 2014 12:48:47 UTC-4, Stodge wrote: >>> >>> My settings for languages are: >>> >>> LANGUAGE_CODE = 'en' >>> >>> USE_I18N = True >>> LANGUAGE_COOKIE_NAME='django_language' >>> ugettext = lambda s: s >>> LANGUAGES = ( >>> ('en', ugettext('English')), >>> ('de', ugettext('German')), >>> ('fr', ugettext('French')) >>> ) >>> >>> >>> I have a post-save signal that creates instances of a model and gets the >>> current Django language. The language returned is for some reason "en-us", >>> but I have no idea where this is coming from. My default as shown above is >>> "en". get_language() is called from within a signal so the language isn't >>> being taken from a cookie or request header. Any ideas why Django thinks >>> the current (default) language is "en-us"? Thanks >>> >>> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68c48096-2929-49e4-afe8-af5f172f61b5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.