Is there a way to create a CSV file to localize a tornado like django makemessage?

Django makemessage can generate i18n files and facilitate translation.

As I see it, the tornado supports CSV and gettext, but I can only use the CSV version, because I will use it with appengine.

So, I'm looking for a way to create these CSV files for a tornado database when scanning my codes and templates.

+6
python tornado internationalization csv localization
source share
2 answers

OK, I think you're a little confused. You can use gettext and po / mo files from appengine, since gettext is exported from the Google implementation django.util (a discussion of this can be found in google- appengine google group ):

from django.utils.translation import gettext as _ 

I am not familiar with the AppEngine CSV i18n format, but there is a very simple way to extract internationalized strings from code and tornado templates using xgettext , just basically force python from the command line. As an example:

  xgettext -L Python -o myproject.pot *.html 

This command will get all i18n 'lines from * .html in your current directory and put them in myproject.pot. You can initialize this file and translate it into let say./it_IT/myproject.po using any commercial or open source tool (I would recommend poedit or pootle ), and once you translate all the lines, you can convert the file to CVS using Translate Toolkit po2csv , which is also written in python:

 po2csv -i it_IT/myproject.po -o it_IT/myproject.csv 

The format location:codeLine,source,target , which is quite simple, can easily be converted to any other format (I am not familiar with the appengine i18n CSV format), you can call po2csv without the -o argument and output the output from STDOUT.

I don’t know if this question solves your question, but basically I think you should accept the code-> pot / po-> csv workflow as there are many tools that expect po / pot / mo and allow you to handle your translations or working with memory translation / spellchecking etc ... try and let me know if you need more help.

+6
source share

I wrote a new module with the goal of tornado-babel , which includes an extractor for babel to extract translatable strings from tornado patterns. It will not create a CSV file for you, but standard pot files.

0
source share

All Articles