Re: Internationalization with gettext

"Alec Matusis" <[email protected]> Thu, 20 Jan 2011 11:06:15 -0800
Newsgroups gmane.comp.python.cheetah
Message-ID <12db01cbb8d5$1d3e7b50$57bb71f0$@com>
Same result with #silent: =

NotFound: cannot find '_'

I think this needs to be clarified, and an example needs to be added to
http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
html  =

Otherwise the internationalization feature  is practically useless to many
developers.

From: James Abbatiello [mailto:[email protected]] =

Sent: Wednesday, January 19, 2011 10:27 PM
To: [email protected]
Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

If you want to include arbitrary Python code try using #silent like this:

#import gettext
#silent t =3D gettext.translation('mymodule', '/home/alec/gettexttest',
('en-US',))
#silent _ =3D t.gettext
$_("This is some text")

-- =

James Abbatiello

On Thu, Jan 20, 2011 at 1:09 AM, Alec Matusis <[email protected]> wrote:
That did not help.
Earlier, I also tried to define function _() like so:

#import gettext
#t =3D gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
#_ =3D t.gettext

This code works in a stand-alone .py file.
Cheetah however still does not find _() function, even with this code at the
top.



From: James Abbatiello [mailto:[email protected]]
Sent: Wednesday, January 19, 2011 7:24 PM
To: [email protected]
Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

I've never used gettext with Cheetah but perhaps including a line like:
#from gettext import gettext as _

at the top of your template might help?

--
James Abbatiello
On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <[email protected]> wrote:
We're trying to translate our templates using Python's gettext module.

>From reading
http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
html
it appears that I need to mark text for translation like this:

$_("This text will be translated")
or like this
$ngettext("This text will be translated")

The templates with marked text compile. Running xgettext (or pygettext.py )
on the compiled template successfully creates the .pot files, but the files
does not contain the marked strings.

Also, running the template produces the following error:

=A0File
"/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
heetah/NameMapper.py", line 246, in valueFromSearchList
=A0 =A0_raiseNotFoundException(key, searchList)
=A0File
"/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
heetah/NameMapper.py", line 167, in _raiseNotFoundException
=A0 =A0raise NotFound(excString)
NotFound: cannot find '_'

which means it cannot find _() function.
Can anybody show me how to mark text for translation?

I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
production, but I believe that 0.9.15 does not have gettext functionality at
all- is that correct?


----------------------------------------------------------------------------
--
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss




---------------------------------------------------------------------------=
---
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand =

malware threats, the impact they can have on your business, and how you =

can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl