W-Mark Kubacki wrote:
> Christoph Zwerschke wrote:
>> W-Mark Kubacki wrote:
>>> Unluckily, with TG 1.0.2.2 FE's messages are neither localizable (no .MO 
>>> created
>>> or added) nor displayed localized (even if apropriate PO was shipped with 
>>> it).
>>> To make things worse what has at least worked with my own validators now 
>>> does not!
>> It is working for me. But I think you need to copy FormEncode's .po 
>> files over to the locale directory of your TG project.
> 
> Does not work.
> 
> To point it out: Although my validators are already translated they're not
> displayed correctly - as if gettext didn't work.

Just checked it out again. You don't even need to copy FormEncode's .po 
file; the .mo file is copied automatically when FormEncode is installed.

Here is how you should get a dummy project running:

* install TurboGears 1.0.2.2

* at the console:
tg-admin quickstart foo
cd foo
tg-admin i18n collect
tg-admin i18n add de

* in welcome.kid, after <body> insert:
   <div py:replace="form()"/>

* replace controllers.py with the following:

------------------------------

from turbogears import controllers, expose, validate, error_handler
from turbogears import widgets, validators

class NoWar(validators.FancyValidator):
     def _(s): return s
     gettextargs = {'domain': 'messages'}
     messages = {'war': _("Don't mention the war!")}
     def validate_python(self, value, state):
         if 'war' in value:
             raise validators.Invalid(
                 self.message('war', state), value, state)

foo_form = widgets.TableForm(
     fields=[widgets.TextField(
         name="Not_Empty", validator=validators.NotEmpty()),
     widgets.TextField(
         name="No_War", validator=NoWar())])

class Root(controllers.RootController):
     @expose(template="foo.templates.welcome")
     @validate(form)
     @error_handler()
     def index(self, **kw):
         return dict(form=foo_form, now='now')

------------------------------

* at the console:
tg-admin i18n collect
tg-admin i18n merge

* in foo/locales/de/LC_MESSAGES/messages.po set:
msgid "Don't mention the war!"
msgstr "War da was?"

* at the console:
tg-admin i18n compile
python start-foo.py

* Both error messages should show up in German,
the standard message from FormEncode if you leave the first field empty,
the custom message "War da was" if you enter "war" in the  second field.

-- Chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to