It stumbles over the number, because in
{{{django/core/management/base.py}}} on line 403
{{{translation.deactivate_all()}}} is called, and later
{{{ _active.value = gettext_module.NullTranslations() }}}
is set.
At least, I found a workaround by setting an explicit language.
Here is the test class to reproduce (if you set: {{{ ACTIVATE_WORKAROUND =
True}}} it will work).
{{{#!py
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from django.template import Context, Template
txt = " {{number}} {{text}}"
class Command(BaseCommand):
def handle(self, *args, **options):
ACTIVATE_WORKAROUND = False
if ACTIVATE_WORKAROUND:
from django.utils import translation
translation.activate("de")
t = Template(txt)
par = {'number': 9009, 'text': 'text', }
c = Context(par)
s = t.render(c)
print s
}}}
To reproduce please unzip website.zip
and run:
{{{
website> manage.py myapp_test
}}}
You will get a lengthy output whichs ends with:
{{{
...
File "D:\Programme\python27\lib\site-packages\django\utils\lru_cache.py",
line 125, in wrapper
result = user_function(*args, **kwds)
File "D:\Programme\python27\lib\site-
packages\django\utils\translation\trans_real.py", line 409, in
check_for_language
if not language_code_re.search(lang_code):
TypeError: expected string or buffer
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24601>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "website.zip" added.
* status: new => closed
* needs_docs: => 0
* resolution: => duplicate
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
It seems this will be fixed in 1.8.1 by #24569.
Also note this related item in the 1.8 release notes:
{{{
* When the leave_locale_alone attribute is False, translations are now
deactivated instead of forcing the “en-us” locale.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24601#comment:1>
Comment (by stephanm):
OK if setting {{{leave_locale_alone=True}}} the error dowsnt appear.
Will there be an 1.8.1 RC version to test?
--
Ticket URL: <https://code.djangoproject.com/ticket/24601#comment:2>
Comment (by timgraham):
There won't be a 1.8.1 RC, but you can test with the stable/1.8.x branch
now.
--
Ticket URL: <https://code.djangoproject.com/ticket/24601#comment:3>