Editing Internationalize a Python application

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 38: Line 38:
       self.set_title ( _("All music") )  <------- ADD THIS!
       self.set_title ( _("All music") )  <------- ADD THIS!
</source>
</source>
 +
== Generate template for the translators ==
 +
 +
Create a po folder in your project (usually at the same level as src/) and run the following command from the top directory of your project. You can do this inside or outside Scratchbox, there is no difference. Don't forget to replace PROJECTNAME with the name of your project.
 +
 +
xgettext --language=Python --keyword=_ --output=po/PROJECTNAME.pot `find . -name "*.py"`
 +
 +
It will parse files, written in Python, looking for strings marked with the keyword (function name) '_' and saving the output in a file called '<code>po/PROJECTNAME.pot</code>'. The list of files is the last argument. I like to use "find", but you can manually put a list of files there.
 +
 +
That command will generate the <code>.pot</code> file. Easy, isn't it?
 +
 +
If you get the error "xgettext: Non-ASCII character at...", try to add the parameter "--from-code=UTF-8" to the command:
 +
 +
xgettext --language=Python --keyword=_ --output=po/PROJECTNAME.pot --from-code=UTF-8 `find . -name "*.py"`
 +
== How to add translations ==
== How to add translations ==

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)