From Mageia wiki
Jump to: navigation, search


Translation into other language is sometimes a very complex thing involving very subtle aspects of the language. Please do not do the things explained below if you have even just a shade of doubt.

In some cases, it is necessary to fix a string in the code, e.g in drak tools.

Normally this ends up in breaking the translations, which is ok, if the meaning of the original string changes. The translators will see those changes in their translation tools and are then able to fix those as well.

When a developer changes a string in the code, she must regenerate the .pot file (which is a template of the strings for a specific software). As a consequence, all .po files (that is, the files which contain the translations, e.g. fr.po or nl.po) will be altered so that the fixed strings are tagged as "fuzzy". It means that since the original string was modified, the translation is probably no longer accurate, so it won't be used until the translators change it/unfuzzy it (and therefore the English string appears in its place). When the fix is just for a typo, the developer can remove the fuzzy tag from all .po files so that the translations are not lost.

In some cases, this can make life easier (or harder) for the translators, e.g. when you are only fixing a typo or a grammatical error in the original string. You can then fix that error without creating unnecessary work for the translators (because most likely they did not create the same typo or grammatical error in their translation).

How to do it

The following examples are part of an email exchange between tv and marja.

For just fixing stuff on a single line, you have to run the same regexp on the pot file and the po files. This can be done with a number of tools like sed or using Perl.

For replacing "Copyright (c) Mandriva" by "Copyright (c) Mageia" you simply have to use a one liner like:

[user@computer ~]$ perl -pi -e 's!Mandriva!Mageia!' if /Copyright \(c\)! po/*.po{t,}
[user@computer ~]$ _

Note, however, that for non-latin languages, names may be translitered, so if a name changes, correction on the translations would be needed too.

Basically tv's rule of thumb is to prevent fuzzing translations when:

  • The fix really is an English typo fix.
  • It is easy to adapt, i.e.
    • adding/removing a final "." or "\n"
    • replacing some hardcoded value by %s (GTK+ placeholder).

Complex examples

Using a placehoder instead hardcoded strings

Replacing "Copyright ..." in a larger text by "%s" because other people already inserted a new "copyright mga" below "copyright mdv".

When you can do something like (untested)

[user@computer ~]$ perl -pi -e '$a = 1 if /^"Copyright/; $a = 2 if $a && /^msgstr/; s!^"Copyright.*Mandriva.*\\"!"%s"! if $a == 2; undef $a if /^msgid/' po/*.po{t,}
[user@computer ~]$ _

Importing translation catalogs

For importing from drakx:

[user@computer ~]$ for i in *.po;do f=../../drakx/perl-install/standalone/po/$i; if [ -e $f ]; then msgmerge -C $f $i $i >l;mv -f l $i;fi;done
[user@computer ~]$ _

GUI: KFileReplace

If all translations are in the same encoding (UTF-8) you can use a sed GUI, KFileReplace.

More on this in the official KDE documentation (just use '*.po;*.pot' template for files). KFileReplace understands strings with newlines, so you can copy them directly in the search textbox.