Thanks, Dalius. It works. But I happened into another encoding issue:

global_test = lazy_gettext(_('Global Test'))

class HelloController(BaseController):
    def test(self):
        return str(global_test)   # Works fine, returns the translated
string

    def test2(self):
        return unicode(global_test)  # It renders the following
traceback

Module ollix.controllers.accounts:26 in signin
<<          g = str(global_test)
            print type(g), g
            return unicode(global_test)
            c.global_test = 'g'
            return render('/accounts/signin.mako')>>  return
unicode(global_test)
Module pylons.i18n.translation:37 in __unicode__
<<
        def __unicode__(self):
            return unicode(self.eval())

        def __str__(self):>>  return unicode(self.eval())
<type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode
byte 0xe5 in position 0: ordinal not in range(128)


I've tried many ways to encode the string to unicode but failed. This
also causes my mako template down. Any suggestion? Thanks.

On Mar 31, 3:02 pm, Dalius Dobravolskas
<[EMAIL PROTECTED]> wrote:
> Olli Wang wrote:
> > Hi, Dalius. I had tried lazy_gettext, but don't know why the
> > lazy_gettext strings won't be collected after I run "python setup.py
> > extract_messages", therefore, I couldn't translate the string. :(
>
> If you are lazier than lazy_gettext do following:
> lazy_gettext(_('your string'))
>
> I have not checked that but I guess extract_messages should collect your
> string now and it will not hit your performance.
>
> Regards,
> Dalius
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to