Difference between revisions of "Translating Audacity"

From Audacity Wiki
Jump to: navigation, search
m (avoid multiple H1 level headings on a page)
(Updating Translations: step by step instructions for doing translation updates (as I see it))
Line 35: Line 35:
  
 
== Updating Translations ==
 
== Updating Translations ==
 +
The most common translation exercise in Audacity development is updating an existing translation for changes in the program or website resulting in new or revised English text to translate. The process is in three parts:
 +
# Extracting all the new English strings from the Audacity source code to create a '''.pot''' file
 +
# Merging the new English strings into the existing '''.po''' file, marking up which ones have changed slightly, and which ones are unchanged.
 +
# Updating the '''.po''' files with new and amended translations.
 +
 +
=== Generating the '''.pot''' file ===
 +
The first step is usually done by the Audacity developers, with the .pot files published on the Audacity website ([http://audacity.sourceforge.net/locale/audacity.pot Audacity .pot file], [http://audacity.sourceforge.net/locale/audacity_website.pot Audacity Website .pot file]).
 +
However if you wish to generate your own pot file from the Audacity sources you can do so:
 +
* For Audacity itself, change directory into the locale directory of the sources, and run
 +
  make audacity.pot
 +
* For the website, change directory into the locale directory of the website sources, and run
 +
  make audacity_website.pot
 +
 +
=== Updating the '''.po''' file with new messages ===
 +
This may be block done by developers at the start of a string freeze, but is likely to be left to translators most of the time. If you have the relevant source code, then you can run
 +
make updatepo
 +
If you just want to update a single .po file, then you can do so using the '''msgmerge''' tool from the gettext tools:
 +
  msgmerge -U yourfile.po newmessages.pot
 +
This will update ''yourfile.po'' with the new messages for translation from ''newmessages.pot''. This will result in a re-written ''yourfile.po'' with the new strings added. Some strings that have slightly changed will be marked up as "Fuzzy" translations, that is the old translation will be kept, but flagged up for a human translator to review later on.
 +
 +
For example to update the pt_BR translation of the Audacity website, you would get the current audacity_website.pot, and run
 +
  msgmerge -U pt_BR.po audacity_website.pot
 +
Now you have a '''.po''' file with new strings in it, and the actual translation can be done.
 +
 +
=== Translating the new strings ===
 +
You can now load the '''.po''' file into your favourite po-file editor, and start to translate.
 +
* If strings are already translated in the '''.po''' file, then they haven't changed, and you should be able to ignore them.
 +
* If strings are marked as Fuzzy translations, then they need to be reviewed against the modified English version to see if the translation is still valid.
 +
* Untranslated strings obviously need to be translated as normal.
 +
Once you have a new translated '''.po''' file, send it in for inclusion in Audacity.
  
 
==Tools==
 
==Tools==

Revision as of 21:35, 3 November 2008

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

The most common translation exercise in Audacity development is updating an existing translation for changes in the program or website resulting in new or revised English text to translate. The process is in three parts:

  1. Extracting all the new English strings from the Audacity source code to create a .pot file
  2. Merging the new English strings into the existing .po file, marking up which ones have changed slightly, and which ones are unchanged.
  3. Updating the .po files with new and amended translations.

Generating the .pot file

The first step is usually done by the Audacity developers, with the .pot files published on the Audacity website (Audacity .pot file, Audacity Website .pot file). However if you wish to generate your own pot file from the Audacity sources you can do so:

  • For Audacity itself, change directory into the locale directory of the sources, and run
 make audacity.pot
  • For the website, change directory into the locale directory of the website sources, and run
 make audacity_website.pot

Updating the .po file with new messages

This may be block done by developers at the start of a string freeze, but is likely to be left to translators most of the time. If you have the relevant source code, then you can run

make updatepo

If you just want to update a single .po file, then you can do so using the msgmerge tool from the gettext tools:

 msgmerge -U yourfile.po newmessages.pot

This will update yourfile.po with the new messages for translation from newmessages.pot. This will result in a re-written yourfile.po with the new strings added. Some strings that have slightly changed will be marked up as "Fuzzy" translations, that is the old translation will be kept, but flagged up for a human translator to review later on.

For example to update the pt_BR translation of the Audacity website, you would get the current audacity_website.pot, and run

 msgmerge -U pt_BR.po audacity_website.pot

Now you have a .po file with new strings in it, and the actual translation can be done.

Translating the new strings

You can now load the .po file into your favourite po-file editor, and start to translate.

  • If strings are already translated in the .po file, then they haven't changed, and you should be able to ignore them.
  • If strings are marked as Fuzzy translations, then they need to be reviewed against the modified English version to see if the translation is still valid.
  • Untranslated strings obviously need to be translated as normal.

Once you have a new translated .po file, send it in for inclusion in Audacity.

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_".