#22900: ugettext_lazy with arguments causes RuntimeError
-------------------------------+------------------------
Reporter: Karmux | Owner: nobody
Type: Uncategorized | Status: new
Component: Translations | Version: 1.7-beta-2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------
If I use arguments with translations I get RuntimeError.
{{{
help_text=_('e.g. %(foo)s or %(bar)s') % {
'foo': 'footxt', 'bar': 'bartxt'})
}}}
This code causes following error:
{{{
Traceback (most recent call last):
File "./manage", line 13, in <module>
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line
21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 106, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py",
line 190, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
import_module
__import__(name)
File "/home/karmo/Dev/project/api/models.py", line 205, in <module>
class Test(Model):
File "/home/karmo/Dev/project/api/models.py", line 222, in Test
'foo': 'footxt', 'bar': 'bartxt'})
File "/usr/local/lib/python2.7/dist-
packages/django/utils/functional.py", line 179, in __mod__
return six.text_type(self) % rhs
File "/usr/local/lib/python2.7/dist-
packages/django/utils/functional.py", line 144, in __text_cast
return func(*self.__args, **self.__kw)
File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/__init__.py", line 83, in ugettext
return _trans.ugettext(message)
File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/trans_real.py", line 317, in ugettext
return do_translate(message, 'ugettext')
File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/trans_real.py", line 298, in
do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/trans_real.py", line 201, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/trans_real.py", line 184, in _fetch
for app_config in reversed(list(apps.get_app_configs())):
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 125, in get_app_configs
self.check_ready()
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 119, in check_ready
raise RuntimeError("App registry isn't ready yet.")
RuntimeError: App registry isn't ready yet.
}}}
Seems it uses non-lazy ugettext in django/utils/translation/__init__.py.
If I remove dictionary from the end of _() then this error disappears.
I'm using Django 1.7b4.
--
Ticket URL: <https://code.djangoproject.com/ticket/22900>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.b5463c3370402e095730dac1c9c088b5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.