id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 16449,i18n_pattern URLs reversed from shell and tests have incorrect language prefix,Jakub Roztočil,nobody,"I've been trying out the new `i18n_patterns` from trunk and have run into the following issue: The `django.core.urlresolvers.reverse()` function always returns `/en-us` as the language prefix for i18n URLs when it is called from a shell session or tests. I don't have `en-us` in my `settings.LANGUAGES` so requests to such URLs result in 404s. After some digging I've found out that the above is probably just a symptom of another issue which is that the language specified in `settings.LANGUAGE_CODE` isn't automatically activated for shell sessions and when running tests: {{{ $ ./manage.py shell >>> from django.conf import settings >>> settings.LANGUAGE_CODE 'es' >>> from django.utils import translation >>> translation.get_language() 'en-us' >>> from django.core.urlresolvers import reverse >>> reverse('test') '/en-us/' }}} I've also tried adding `en-us` as `settings.LANGUAGE_CODE` and to `settings.LANGUAGES`, after which I was able to run my tests, but there was another issue: the `get_language_info` template tag raises an exception when the language code is `en-us`, because it isn't defined in `django.conf.locale.LANG_INFO`: {{{ $ ./manage.py shell >>> from django.utils import translation >>> translation.get_language_info('en-us') --------------------------------------------------------------------------- KeyError Traceback (most recent call last) django/utils/translation/__init__.pyc in get_language_info(lang_code) 165 from django.conf.locale import LANG_INFO 166 try: 167 return LANG_INFO[lang_code] 168 except KeyError: --> 169 raise KeyError(""Unknown language code %r."" % lang_code) KeyError: ""Unknown language code 'en-us'."" }}} ",Bug,closed,Translations,dev,Normal,worksforme,"urlconf, reverse, i18n_patterns, tests, shell",,Unreviewed,0,0,0,0,0,0