Re: Internationalization with gettext
James Abbatiello <[email protected]> Wed, 19 Jan 2011 22:23:46 -0500
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
--===============9026507919893778683== Content-Type: multipart/alternative; boundary=000e0cd1872058c104049a3ea967 --000e0cd1872058c104049a3ea967 Content-Type: text/plain; charset=ISO-8859-1 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<http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.%0Ahtml> > 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: > > File > > "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C > heetah/NameMapper.py", line 246, in valueFromSearchList > _raiseNotFoundException(key, searchList) > File > > "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C > heetah/NameMapper.py", line 167, in _raiseNotFoundException > raise 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 > --000e0cd1872058c104049a3ea967 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I've never used gettext with Cheetah but perhaps including a line like:= <br>#from gettext import gettext as _<br><br>at the top of your template mi= ght help?<br><br>-- <br>James Abbatiello<br><br><div class=3D"gmail_quote"> On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]">[email protected]</a>></span> wrote:<b= r><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:= 1px #ccc solid;padding-left:1ex;"> We're trying to translate our templates using Python's gettext modu= le.<br> <br> >From reading<br> <a href=3D"http://www.cheetahtemplate.org/docs/users_guide_html_multipage/t= ips.gettext.%0Ahtml" target=3D"_blank">http://www.cheetahtemplate.org/docs/= users_guide_html_multipage/tips.gettext.<br> html</a><br> it appears that I need to mark text for translation like this:<br> <br> $_("This text will be translated")<br> or like this<br> $ngettext("This text will be translated")<br> <br> The templates with marked text compile. Running xgettext (or pygettext.py )= <br> on the compiled template successfully creates the .pot files, but the files= <br> does not contain the marked strings.<br> <br> Also, running the template produces the following error:<br> <br> =A0File<br> "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686= .egg/C<br> heetah/NameMapper.py", line 246, in valueFromSearchList<br> =A0 =A0_raiseNotFoundException(key, searchList)<br> =A0File<br> "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686= .egg/C<br> heetah/NameMapper.py", line 167, in _raiseNotFoundException<br> =A0 =A0raise NotFound(excString)<br> NotFound: cannot find '_'<br> <br> which means it cannot find _() function.<br> Can anybody show me how to mark text for translation?<br> <br> I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in<br> production, but I believe that 0.9.15 does not have gettext functionality a= t<br> all- is that correct?<br> <br> <br> ---------------------------------------------------------------------------= ---<br> Protect Your Site and Customers from Malware Attacks<br> Learn about various malware tactics and how to avoid them. Understand<br> malware threats, the impact they can have on your business, and how you<br> can protect your company and customers by using code signing.<br> <a href=3D"http://p.sf.net/sfu/oracle-sfdevnl" target=3D"_blank">http://p.s= f.net/sfu/oracle-sfdevnl</a><br> _______________________________________________<br> Cheetahtemplate-discuss mailing list<br> <a href=3D"mailto:[email protected]">Cheetahtem= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-dis= cuss" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/cheeta= htemplate-discuss</a><br> </blockquote></div><br> --000e0cd1872058c104049a3ea967-- --===============9026507919893778683== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ 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 --===============9026507919893778683== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss --===============9026507919893778683==--