Opened 18 years ago
Closed 18 years ago
#4295 closed (fixed)
[unicode] smart_unicode does not work well with lazy objects
Reported by: | Malcolm Tredinnick | Owned by: | Malcolm Tredinnick |
---|---|---|---|
Component: | Core (Other) | Version: | other branch |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
We are adopting a very "eager" conversion approach with unicode string: calling smart_unicode() as early as possible. This leads to problem with objects coming from ugettext_lazy() and friends. In the current smart_unicode() implementation, they are converted immediately to unicode strings, which is quite possibly (even likely, in some cases) to be in the wrong locale. If we uncomment the commented-out block at the top of the function, things are a little better with respect to translations, but now the code breaks elsewhere because a lot of things assume smart_unicode() returns something we can directly use as a string.
So I need to remember to fix this.
I tried to implement a kind of smart_unicode_lazy in [4904] on trunk, but it didn't work. One problem is that u''.join(l)
doesn't work if l
contains lazy objects.
I suspect we need to do a full audit of places where smart_unicode could be being used with lazy translation objects and handle them specially if they are not just done at render-time.
(In [5314]) unicode: Made lazy translation objects work properly. Fixed #4295, #4320.