Code

Opened 7 years ago

Closed 7 years ago

#4295 closed (fixed)

[unicode] smart_unicode does not work well with lazy objects

Reported by: mtredinnick Owned by: mtredinnick
Component: Core (Other) Version: other branch
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:

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 (0)

Change History (1)

comment:1 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.