Django

Code

Ticket #4295 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[unicode] smart_unicode does not work well with lazy objects

Reported by: mtredinnick Assigned to: mtredinnick
Milestone: Component: Core framework
Version: other branch Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation:
Needs tests: Patch needs improvement:

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.

Attachments

Change History

05/22/07 03:06:57 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5314]) unicode: Made lazy translation objects work properly. Fixed #4295, #4320.


Add/Change #4295 ([unicode] smart_unicode does not work well with lazy objects)




Change Properties
Action