Extracting gettext messages from coffeescript files

Is there any library that can extract gettext messages directly from coffeescript files or do I need to compile them to javascript and extract only then?

I've been using python babel module for message extraction, could be good if coffeescript extraction function existed for it.

Answers


As far as I know there is no extractor for coffeescript - if you find one, please please drop us a note. Patches welcome as well :-)


Messages can actualy be exctracted from .coffee files using plain old xgettext using --language=C without any additional effort as long as these conditions are met:

  1. gettext functions parameters have to be ALWAYS enclosed inside brackets
  2. String parameters have to be ALWAYS within double quotes (they must not be in single quotes)

Any deviation from those two conditions will result in xgettext ignoring the message


I had good results with Poedit; I used it to check my source coffee files against strings like

t('Translatable str')

You have to add a coffeescript parser in the preferences and configure it like so:

  • Language : Coffee
  • List of extensions: *.jade,*.js,*.coffee
  • Parser command : xgettext --language=perl --force-po -o %o %C %K %F
  • An item in keyword list : -k%k
  • An item in input : %f
  • Source code charset : --from-code=%c

I have then a *.po file that contains my translations.. I went further and created a grunt plugin to help me transfer the po to JSON :)

Notes:

  • Poedit will ignore strings starting with dashes as it thinks they are comment; #{t('This wont be translated!')}
  • You can also try using Python in the parser command language; it detects more strings but with warnings!

Need Your Help

Amazon Load Balancer sticky sessions configuration for jsessionid in URL

tomcat amazon-web-services load-balancing jsessionid

I currently trying to setup Amazon Load Balancer for Tomcat workers, but I faced one problem.

Toggle function not working when called

javascript toggle

The idea is to make two div appear or disappear based on the click. The CSS display style is set to none.