Ask Your Question
1

What do you use for extrarcting messages from javascript files

asked 2012-04-27 01:41:33 -0500

Basel Shishani gravatar image Basel Shishani
197 7 2 14

updated 2012-04-27 07:00:48 -0500

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.

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-04-27 04:10:21 -0500

zaf gravatar image zaf
554 8 8 26

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.

link publish delete flag offensive edit

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 ( 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 ( 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 ( 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 ( 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 ( 2012-04-27 10:15:09 -0500 )edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-04-27 01:41:33 -0500

Seen: 89 times

Last updated: Apr 27 '12