Opened 18 years ago

Closed 18 years ago

#4152 closed (fixed)

[unicode] Unicode-aware translation

Reported by: Ivan Sagalaev <Maniac@…> Owned by: Malcolm Tredinnick
Component: Uncategorized Version: other branch
Severity: Keywords: unicode
Cc: Maniac@…, mir@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description


Attachments (3)

4152.diff (1022 bytes ) - added by Ivan Sagalaev <Maniac@…> 18 years ago.
Patch for template tags
4152.cumulative.diff (16.7 KB ) - added by Ivan Sagalaev <Maniac@…> 18 years ago.
Cumulative patch
4152.2.cumulative.diff (44.6 KB ) - added by Ivan Sagalaev <Maniac@…> 18 years ago.
Cumulative patch including oldforms and core.validators

Download all attachments as: .zip

Change History (9)

comment:1 by Ivan Sagalaev <Maniac@…>, 18 years ago

Cc: Malcolm Tredinnick Maniac@… added

I've made two flavors of a patch. First one only fixes template tags for translations (and is very small). Another includes the first one plus replaces [n]gettext* -> u[n]gettext in db fields, newforms fields. Things to think of:

  • Malcolm, despite your observations _(u'something in russian') doesn't break anything including make-messages.py. But I didn't change arguments to _() because they should be in English anyway
  • newforms' fields.py uses gettext(u'...') all over the place. I think they should be converted to '...' for consistency but this didn't make it into the patch. If there are no objections I'll convert them.
  • I didn't touch core.validators at all because they are intended for oldforms that aren't unicode aware. However they are used in db.models.fields (EMailField for example). After converting things to ugettext this leads to some validation messages being in unicode and some in byte strings (see tests/modeltests/validation/models.py lines 45 -- unicode and 147 -- byte strings). I believe the best way is to convert core.validators to unicode and forget oldforms. Thoughts?

by Ivan Sagalaev <Maniac@…>, 18 years ago

Attachment: 4152.diff added

Patch for template tags

by Ivan Sagalaev <Maniac@…>, 18 years ago

Attachment: 4152.cumulative.diff added

Cumulative patch

comment:2 by Ivan Sagalaev <Maniac@…>, 18 years ago

Summary: [unicode] Unicode-aware translation[unicode][patch] Unicode-aware translation

comment:3 by mir@…, 18 years ago

Cc: mir@… added

comment:4 by Malcolm Tredinnick, 18 years ago

Cc: Malcolm Tredinnick removed
Has patch: set
Owner: changed from Jacob to Malcolm Tredinnick
Summary: [unicode][patch] Unicode-aware translation[unicode] Unicode-aware translation
Triage Stage: UnreviewedAccepted

Ivan,

  • Not sure why you aren't seeing errors in make-messages.py. I get them all the time with both gettext 0.14.5 and gettext 0.16.1. Most odd. It's documented as not valid for gettext msg ids anyway.
  • There's no problem with using u".." strings inside the gettext() calls providing they use ASCII characters. xgettext only looks for the quotes anyway. I haven't been bothering to change them in localflavor/ contributions.
  • Old forms is deprecated, not absent. We need to fix oldforms, too, for backwards compatibility. I don't know if oldforms will still be present in 1.0 or not (I would guess, yes, but import forms will import newforms by default). We can't break the tree once unicode is merged with trunk and there's a lot of code still using oldforms. I'll fix that up, though, it's not too hard, I suspect.

Patch looks good from just reading it through once. I'll merge it tonight. Thanks.

(Oh, and stop putting [patch] in the title. There's a checkbox for that. Using "[patch]" makes it look like you're still living in 2006.)

in reply to:  4 comment:5 by Ivan Sagalaev <Maniac@…>, 18 years ago

  • Not sure why you aren't seeing errors in make-messages.py. I get them all the time with both gettext 0.14.5 and gettext 0.16.1. Most odd. It's documented as not valid for gettext msg ids anyway.

Yes, I just noted this as a strange fact, not for using it :-)

  • There's no problem with using u".." strings inside the gettext() calls providing they use ASCII characters. xgettext only looks for the quotes anyway. I haven't been bothering to change them in localflavor/ contributions.

I thought that this may be misleading for people reading source and thinking "if it can accept unicode I could use my native language as a base for translation".

  • Old forms is deprecated, not absent. We need to fix oldforms, too, for backwards compatibility. I don't know if oldforms will still be present in 1.0 or not (I would guess, yes, but import forms will import newforms by default). We can't break the tree once unicode is merged with trunk and there's a lot of code still using oldforms. I'll fix that up, though, it's not too hard, I suspect.

I actually have core.validators converted locally, I'll just update the patch in a few hours.

(Oh, and stop putting [patch] in the title. There's a checkbox for that. Using "[patch]" makes it look like you're still living in 2006.)

Ouch :-). Perhaps I was trying too hard to get used to it and now it strikes back :-).

by Ivan Sagalaev <Maniac@…>, 18 years ago

Attachment: 4152.2.cumulative.diff added

Cumulative patch including oldforms and core.validators

comment:6 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [5082]) unicode: Fixed #4152 -- Converted a lot of internal [n]gettext() calls into
u[n]gettext() calls. Thanks, Ivan Sagalaev.

Note: See TracTickets for help on using tickets.
Back to Top