First time here? Check out the FAQ!
1

What do you use for extrarcting messages from javascript files

There are known issues with gettext message exraction for js files. makemessages skips aronud a third of the messages (in askbot). xgettext does not support js, but can be used with --language=python, but still skips messages.

[

To use makemessages with javascript message in a separate djangojs domain:

manage.py makemessages -d djangojs -l fr

(makemessages understands that this domain is for messages from js files - by the look of it)

To use xgettext, which works only on individual files:

xgettext --language=python --from-code=utf-8  post.js

]

I posted a question about the Babel extractor on SO here, which their docs say can be used for js message extraction, but didn't get an answer.

I'm wondering what others who are localizing askbot are using for this, maybe you're using your own concocted script or doing it manually, or you know some better tool.

I thought to raise this here anyway as others might hit the issue.

Basel Shishani's avatar
197
Basel Shishani
asked 2012-04-27 01:41:33 -0500, updated 2012-04-27 07:00:48 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

I use jinja2_makemessages to generate translation pairs and get po files updated. So instead of makemessages I run

python manage.py jinja2_makemessages --no-wrap -l <language> -e html,py,txt

where in <language> you put en,ro, or whatever language you use. Check this post for more instructions and this one for a work around you may need.

zaf's avatar
512
zaf
answered 2012-04-27 04:10:21 -0500
edit flag offensive 0 remove flag delete link

Comments

Actually I'm not sure if my answer covers you coz I don't know if it handles javascript files. It's just what I use by following the mentioned instructions. Curious to know if that's correct. Anyone?

zaf's avatar zaf (2012-04-27 04:23:00 -0500) edit

The command you provided works for the generic domain, for Javascript files a separate domain (djangojs) is used. I edited the question to add examples. jinja2_makemessages does not improve on makemessages when it comes to js, it's meant to improve handling template files.

Basel Shishani's avatar Basel Shishani (2012-04-27 06:51:57 -0500) edit

And the workaround you pointed to is to work around a shortcoming in jinja2_makemessages when handling template files. So there are two separate issues, one re template files (which is more or less resolved), and another with js files, which is the subject of this posting. Regards.

Basel Shishani's avatar Basel Shishani (2012-04-27 07:05:19 -0500) edit

That command does not handle javascript - you need to specify -d djangojs and there is no need to give file extensions. The command will create a separate .po file, which is a bit unfortunate, because there may be some phrases present in both django.po and djangojs.po and you have to translate them twice.

Evgeny's avatar Evgeny (2012-04-27 09:32:52 -0500) edit
1

The separation of javascript messages into a separate domain (eqv to namespaces) is natural as the catalog might be passed to the client (am not sure if that's how askbot does things). There are other good reasons to have namespaces for messages. The blame should be squared on the deficient gettext where you can't provide inter-references between message entities in different domains (this is just a minor issue compared to its many shortcomings).

Basel Shishani's avatar Basel Shishani (2012-04-27 10:15:09 -0500) edit
add a comment see more comments