Re: Internationalization with gettext

James Abbatiello <[email protected]> Sat, 22 Jan 2011 02:03:03 -0500
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
--===============0155817045891131430==
Content-Type: multipart/alternative; boundary=001636e8fed6398b1c049a69f51e

--001636e8fed6398b1c049a69f51e
Content-Type: text/plain; charset=ISO-8859-1

Can you post a complete minimal example that isn't working for you?

-- 
James Abbatiello


On Thu, Jan 20, 2011 at 2:06 PM, Alec Matusis <[email protected]> wrote:

> 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<http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.%0Ahtml>
> 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 = gettext.translation('mymodule', '/home/alec/gettexttest',
> ('en-US',))
> #silent _ = 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 = gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
> #_ = 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<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
>
>
>
>

--001636e8fed6398b1c049a69f51e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Can you post a complete minimal example that isn&#39;t working for you?<br>=
<br>-- <br>James Abbatiello<br><br><br>On Thu, Jan 20, 2011 at 2:06 PM, Ale=
c Matusis <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]">matu=
[email protected]</a>&gt;</span> wrote:<br>
<div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Same result with=
 #silent:<br>
NotFound: cannot find &#39;_&#39;<br>
<br>
I think this needs to be clarified, and an example needs to be added to<br>
<div class=3D"im"><a href=3D"http://www.cheetahtemplate.org/docs/users_guid=
e_html_multipage/tips.gettext.%0Ahtml" target=3D"_blank">http://www.cheetah=
template.org/docs/users_guide_html_multipage/tips.gettext.<br>
html</a><br>
</div>Otherwise the internationalization feature =A0is practically useless =
to many<br>
developers.<br>
<div class=3D"im"><br>
From: James Abbatiello [mailto:<a href=3D"mailto:[email protected]">abbeyj@g=
mail.com</a>]<br>
</div>Sent: Wednesday, January 19, 2011 10:27 PM<br>
<div><div></div><div class=3D"h5">To: <a href=3D"mailto:cheetahtemplate-dis=
[email protected]">[email protected]</=
a><br>
Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext<br=
>
<br>
If you want to include arbitrary Python code try using #silent like this:<b=
r>
<br>
#import gettext<br>
#silent t =3D gettext.translation(&#39;mymodule&#39;, &#39;/home/alec/gette=
xttest&#39;,<br>
(&#39;en-US&#39;,))<br>
#silent _ =3D t.gettext<br>
$_(&quot;This is some text&quot;)<br>
<br>
--<br>
James Abbatiello<br>
<br>
On Thu, Jan 20, 2011 at 1:09 AM, Alec Matusis &lt;<a href=3D"mailto:matusis=
@matusis.com">[email protected]</a>&gt; wrote:<br>
That did not help.<br>
Earlier, I also tried to define function _() like so:<br>
<br>
#import gettext<br>
#t =3D gettext.translation(&#39;mymodule&#39;, &#39;/home/alec/gettexttest&=
#39;, (&#39;en-US&#39;,))<br>
#_ =3D t.gettext<br>
<br>
This code works in a stand-alone .py file.<br>
Cheetah however still does not find _() function, even with this code at th=
e<br>
top.<br>
<br>
<br>
<br>
From: James Abbatiello [mailto:<a href=3D"mailto:[email protected]">abbeyj@g=
mail.com</a>]<br>
Sent: Wednesday, January 19, 2011 7:24 PM<br>
To: <a href=3D"mailto:[email protected]">cheeta=
[email protected]</a><br>
Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext<br=
>
<br>
I&#39;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 might help?<br>
<br>
--<br>
James Abbatiello<br>
On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis &lt;<a href=3D"mailto:matusis=
@matusis.com">[email protected]</a>&gt; wrote:<br>
We&#39;re trying to translate our templates using Python&#39;s gettext modu=
le.<br>
<br>
&gt;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>
$_(&quot;This text will be translated&quot;)<br>
or like this<br>
$ngettext(&quot;This text will be translated&quot;)<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>
&quot;/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686=
.egg/C<br>
heetah/NameMapper.py&quot;, line 246, in valueFromSearchList<br>
=A0 =A0_raiseNotFoundException(key, searchList)<br>
=A0File<br>
&quot;/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686=
.egg/C<br>
heetah/NameMapper.py&quot;, line 167, in _raiseNotFoundException<br>
=A0 =A0raise NotFound(excString)<br>
NotFound: cannot find &#39;_&#39;<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>
--<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>
<br>
<br>
<br>
</div></div></blockquote></div><br>

--001636e8fed6398b1c049a69f51e--


--===============0155817045891131430==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
--===============0155817045891131430==
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

--===============0155817045891131430==--