librelist archives

« back to archive

Help with pybabel

Help with pybabel

From:
Alberto Piu
Date:
2011-08-15 @ 18:34
Hi,

I'm sorry I'm bothering again, but it seems there's not information about 
this error
online. I found an IRC log (this one: 
http://dev.pocoo.org/irclogs/%23pocoo.2010-11-29.log) 
but no one answered the question.

I'm following the directions at Flask-Babel page, here: 
http://packages.python.org/Flask-Babel/#translating-applications

I did install Babel and create the .cfg, but when running this:

	$ pybabel extract -F babel.cfg -o messages.pot

I get the error:

> pybabel: error: incorrect number of arguments

I thought that I need to provide the directory with the .html templates, so I did:

	$ pybabel extract -F babel.cfg -o messages.pot templates/

This works, but I get an empty .pot (with no strings to translate). I 
don't know if this is expected,
but I actually put a translatable string in a file templates/template.html
by calling:

	{{ _("translatable") }}

Is this an expected behaviour?

Thank you in advance.
Alberto

Re: [flask] Help with pybabel

From:
Julen Ruiz Aizpuru
Date:
2011-08-15 @ 19:14
al., 2011.eko aburen 15a 20:34(e)an, Alberto Piu(e)k idatzi zuen:
> Hi,
>
> I'm sorry I'm bothering again, but it seems there's not information 
about this error
> online. I found an IRC log (this one: 
http://dev.pocoo.org/irclogs/%23pocoo.2010-11-29.log)
> but no one answered the question.
>
> I'm following the directions at Flask-Babel page, here: 
http://packages.python.org/Flask-Babel/#translating-applications
>
> I did install Babel and create the .cfg, but when running this:
>
> 	$ pybabel extract -F babel.cfg -o messages.pot
>
> I get the error:
>
>> pybabel: error: incorrect number of arguments

The online docs are wrong, they're correct in github — that needs an 
update I guess:

https://github.com/mitsuhiko/flask-babel/commit/96bb4f09a18f1c1a3daaef8acf40d9518288e0d9

> I thought that I need to provide the directory with the .html templates,
so I did:
>
> 	$ pybabel extract -F babel.cfg -o messages.pot templates/
>
> This works, but I get an empty .pot (with no strings to translate). I 
don't know if this is expected,
> but I actually put a translatable string in a file 
templates/template.html by calling:
>
> 	{{ _("translatable") }}
>
> Is this an expected behaviour?

I'm also experiencing an odd behaviour when extracting strings: all the 
extraction works fine except for the main template. Its strings are 
being mysteriously ignored.

As a weird workaround I'm copying the few strings in the main template 
to a separate py file so they can be caught in the extraction process.

Re: [flask] Help with pybabel

From:
Alberto Piu
Date:
2011-08-15 @ 19:56
Hi Julen,

thanks for your reply. Now everything is working fine. :-)

Alberto

Il giorno 15/ago/2011, alle ore 21:14, Julen Ruiz Aizpuru ha scritto:

> al., 2011.eko aburen 15a 20:34(e)an, Alberto Piu(e)k idatzi zuen:
>> Hi,
>> 
>> I'm sorry I'm bothering again, but it seems there's not information 
about this error
>> online. I found an IRC log (this one: 
http://dev.pocoo.org/irclogs/%23pocoo.2010-11-29.log)
>> but no one answered the question.
>> 
>> I'm following the directions at Flask-Babel page, here: 
http://packages.python.org/Flask-Babel/#translating-applications
>> 
>> I did install Babel and create the .cfg, but when running this:
>> 
>> 	$ pybabel extract -F babel.cfg -o messages.pot
>> 
>> I get the error:
>> 
>>> pybabel: error: incorrect number of arguments
> 
> The online docs are wrong, they're correct in github — that needs an 
> update I guess:
> 
https://github.com/mitsuhiko/flask-babel/commit/96bb4f09a18f1c1a3daaef8acf40d9518288e0d9
> 
>> I thought that I need to provide the directory with the .html 
templates, so I did:
>> 
>> 	$ pybabel extract -F babel.cfg -o messages.pot templates/
>> 
>> This works, but I get an empty .pot (with no strings to translate). I 
don't know if this is expected,
>> but I actually put a translatable string in a file 
templates/template.html by calling:
>> 
>> 	{{ _("translatable") }}
>> 
>> Is this an expected behaviour?
> 
> I'm also experiencing an odd behaviour when extracting strings: all the 
> extraction works fine except for the main template. Its strings are 
> being mysteriously ignored.
> 
> As a weird workaround I'm copying the few strings in the main template 
> to a separate py file so they can be caught in the extraction process.