I'm working on improvements to this new USE_I18N setting I added
yesterday, and I've run into a bit of a problem --
In my local Django sandbox, I've turned django.utils.translation into
a package that contains __init__.py, trans_real.py and trans_null.py.
The __init__.py contains this:
from django.conf import settings
if settings.USE_I18N:
from trans_real import *
else:
from trans_null import *
trans_real.py is the former django/utils/translation.py, and
trans_null.py contains identity versions of the gettext(), etc.,
functions that don't actually do anything. This is a nice, clean way
of avoiding the overhead of all that gettext() stuff if USE_I18N is
set to False.
The problem with this arrangement is that it causes any import of
django.utils.translation to load django.conf.settings -- and the
settings file in itself imports the translation hooks, because of the
LANGUAGES setting in global_settings.py:
from django.utils.translation import gettext_lazy as _
LANGUAGES = (
('bn', _('Bengali')),
('cs', _('Czech')),
('cy', _('Welsh')),
('da', _('Danish')),
('de', _('German')),
# ...
)
So, in order to make this work, I'm proposing that we *disallow*
translation strings in settings files -- so that the
django.utils.translation file can import from settings and we avoid
circular import references.
This leaves the problem: Where do we put the translation strings for
the available languages? For that, we could put the translation
strings in in django/utils/translation/trans_null.py and change any
instance of LANGUAGES to apply the gettext call at runtime rather than
compile time. Or is there a better way to solve the problem?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---