Question

I found this cool js gettext library -> http://code.google.com/p/gettext-js/ but I don't understand how to implement it. I am using poedit to edit the translations and I can see that it works when I checkout the project and run the demo file but when I make changes to the text, the .po files don't get updated and I can't see the new text. Does anybody have any idea? Thanks!

Was it helpful?

Solution

"I also had to force python in the gettext command":

  1. File|Preferences|Parsers
  2. Edit Python
  3. Edit "List of extensions..":
  4. *.py;*.js
  5. Edit "Parser commend:"
  6. xgettext --language=Python --force-po -o %o %C %K %F

Done.

Thanks for leading me there Kentor :)

OTHER TIPS

I think xgettext --language=perl --force-po -o %o %C %K %F (using perl rather than python) shall be a better options, as python cause problem with javascript comment which contains a single quote (unterminated string error).

You must invoke xgettext in order to extract the strings into a .pot file, and then run msgmerge to update the .po files. The gettext manual has all the gory details.

I initially tried with both configurations, Python & Perl but with some complex underscore templates, nested quotes and double quotes, escaped characters etc. both parsers reported loads of false obsolete strings so I cannot update the .pot or .po files properly from source code.

I also tested without success http://code.google.com/p/gettext-js/

After a lot of trial & error I discovered I can use chaining parsing and it worked fine on poedit 1.5.7. These are the configuration parameters that should be enabled at the same time for the best matching

Extracted from Library/Preferences/net.poedit.Poedit.cfg of the Mac version, you can simply copy and paste on your dialog otherwise

[Parsers/js] 
Extensions=*.js;*.html 
Command=xgettext --language=Python --force-po -o %o %C %K %F 
KeywordItem=-k%k 
FileItem=%f 
CharsetItem=--from-code=%c 

[Parsers/PHP] 
Extensions=*.php;*.js;*.html 
Command=xgettext --language=PHP --force-po -o %o %C %K %F 
KeywordItem=-k%k 
FileItem=%f 
CharsetItem=--from-code=%c 

Notice that you may don't need to include *.html on your extensions, I did it to parse my underscore templates. Hope it helps cause it was really frustrating for me :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top