Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1999 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

[patch] i18n fix for FormEncode & ToscaWidgets

Reported by: TimurIzhbulatov Owned by: faide
Priority: highest Milestone: 2.0b6
Component: TurboGears Version: trunk
Severity: normal Keywords: i18n toscawidgets formencode gettext
Cc:

Description

This patch sets a translator for ToscaWidgets? middleware and adds a request specific translator for standard FormEncode messages.

For the later purpose it uses an approach similar to the one used in Pylons but doesn't rely on formencode.api._stdtrans module global which is a gettext.NullTranslations? instance created at module import time. Instead, a request specific translation object is created and saved in tmpl_context.

Attachments

tw-fe-i18n.diff Download (5.1 KB) - added by TimurIzhbulatov 10 years ago.
tg2-tw-i18n.tar.gz Download (94.9 KB) - added by TimurIzhbulatov 10 years ago.

Change History

comment:1 Changed 11 years ago by Chris Arndt

  • Owner changed from faide to mramm

comment:2 Changed 10 years ago by TimurIzhbulatov

  • Milestone changed from 1.9.7a5 to 2.0b1

comment:3 Changed 10 years ago by faide

  • Status changed from new to assigned
  • Owner changed from mramm to faide

comment:4 Changed 10 years ago by mramm

  • Milestone changed from 2.0b1 to 2.0b2

comment:5 Changed 10 years ago by percious

  • Owner changed from faide to percious
  • Status changed from assigned to new

comment:6 Changed 10 years ago by mramm

  • Milestone changed from 2.0b2 to 2.0b3

comment:7 Changed 10 years ago by mramm

  • Milestone changed from 2.0b3 to 2.0b4

comment:8 Changed 10 years ago by mramm

  • Owner changed from percious to faide

comment:9 Changed 10 years ago by mramm

  • Priority changed from normal to highest

Changed 10 years ago by TimurIzhbulatov

comment:10 Changed 10 years ago by TimurIzhbulatov

I've updated the patch for current trunk, and it also works with 2.0b5.1. The test project I used for verification is attached.

Besides internationalized widgets, the project includes translated messages collected from controller code and template (please see i18n/ru/LC_MESSAGES/tg2twi18n.po).

The language is set to Russian in development.ini (lang = ru), so you'll need to comment it out to see the original untranslated messages.

Changed 10 years ago by TimurIzhbulatov

comment:11 Changed 10 years ago by mramm

From here this patch looks good, and I played with it and it seems OK as Timur suggests. Florent, Alberto, Percious, could you comment?

This patch is a blocker for b6 at this point.

comment:12 Changed 10 years ago by faide

At one point I assigned that ticket to myself... I'll try to give a look :)

comment:13 follow-up: ↓ 14 Changed 10 years ago by Gustavo

I think the patch is good, but:

  • In controllers.py, line 844 should be a WARN and 851 a INFO, from my point of view.
  • There's a comment on pylons_formencode_gettext() which states that it basically comes from Pylons and I couldn't find anything TG-specific, so why don't we use Pylons' implementation?

comment:14 in reply to: ↑ 13 Changed 10 years ago by Gustavo

Please ignore the following, the answer was in the ticket's description -- I had to read it all first:

Replying to Gustavo:

  • There's a comment on pylons_formencode_gettext() which states that it basically comes from Pylons and I couldn't find anything TG-specific, so why don't we use Pylons' implementation?

comment:15 Changed 10 years ago by faide

Sorry but this patch breaks a lot of tests.

the setup_i18n function is not properly called during the tests and we get missing attributes in the validation tests because the controller cannot find pylons.c.formencode_translation

This means I have 5 failing tests and I could not find a simple solution to fix those. I cannot take the risk to apply that patch as-is. We should fix those tests before it can go in.

comment:16 Changed 10 years ago by faide

In fact the function is called but I think the language cannot ne retrieved during the tests and thus the:

pylons.c.formencode_translation

attribute cannot be set. This is a test problem because in a live app the language will be properly detected and the attr will be present.

comment:17 Changed 10 years ago by faide

I fixed all the tests. I need some time to cleanup the mess and I'll commit this :)

comment:18 Changed 10 years ago by faide

Applied to r6421 Please review the change regarding the log levels because I did that in a hurry.

comment:19 Changed 10 years ago by faide

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.