Translating Audacity

From Audacity Wiki
Revision as of 20:55, 3 November 2008 by Richardash1981 (talk | contribs) (Tools: add kbabel as well as poedit, sort out the heading levels + add a new section for updating translations)
Jump to: navigation, search

Audacity is localized into many languages.

Source Code

In the source code, strings which are to be translated are written like so:

 _("A string to be translated")

Such strings are detected by the 'xgettext' utility.

Strings which are not to be translated are written like so:

 wxT("Don't translate this")

The wxT() allows us to build Unicode versions of Audacity.

When strings span several lines we place a '\' at the end of each line, and continue immediately at the start of the next line. We have tried various other ways of dealing with long strings, but the other ways we've tried either don't work when compiling with Unicode, or defeat detection by xgettext.

To enable translation, rather than write strings like this:

 wxString(_("The file " )) + filename + _("could not be found.")

Use instead:

 wxString::Format(_("The file %s could not be found"), filename.c_str )

This gives the translator a complete sentence to work with, rather than the fragments "this file " and "could not be found.", which due to alphabetical sorting could be well separated in the .po file.

Some parts of the source code contain html text. The html tags are not to be translated. In addition in places these embedded html strings have hyperlinks in wiki syntax, like so:

 [[export|Exporting to MP3]]

In the .po file, translators should translate the second part, but not the first part.


Updating Translations

Tools

Tools used in translation:

poEdit

This is a wxWidgets based editor for the translation files.

Kbabel

The translation tool from the KDE desktop environment can also be used to edit PO files for other projects.

xggettext

A utility to extract the translatable strings from the source code. This is bundled with poEdit.

Note that under windows there is a bug in xgettext, and that in order to get it to detect all strings inside the '_()' brackets, you must use the option "-k_".