Fallstricke

Es gibt einige typische Fehler, denen Sie möglicherweise auch selbst begegnen werden. Dieser Abschnitt könnte Ihnen dabei helfen, dies zu vermeiden.

27.4.1. Gleiche Zeichenketten, unterschiedliche Semantik

Sometimes two english strings are identical but have different meanings in different contexts, so they would probably not be identical when translated. Since the English strings are used as look-up keys, this causes problems.

In these cases, you should add extra characters to the strings. For instance, use "jumps[noun]" and "jumps[verb]" instead of just "jumps") and strip them again outside the gettext call. If you add extra characters you should also add a comment for the translators before the gettext call. Such comments will be shown in the .po files. For instance:

// note to translators: don't translate the "[noun]" part - it is
// just here to distinguish the string from another "jumps" string
text = strip(gettext("jumps[noun]"), "[noun]");

27.4.2. Zusammenstellung der Zeichenketten

C programmers use sprintf() to compose and concatenate strings. C++ favours streams, but unfortunately, this approach makes translation difficult, because each fragment of text is translated separately, without allowing the translators to rearrange them according to the grammar of the language.

Folgendes könnte beispielsweise problematisch sein:

std::cout << _("Current amount: ") << amount
          << _(" Future: ") << future << std::endl;

label.set_text(_("Really delete ") + filename + _(" now?"));

So you should either avoid this situation or revert to the C-style sprintf(). One possible solution is the compose library which supports syntax such as:

label.set_text(compose(_("Really delete %1 now?"), filename));

27.4.3. Einschätzen der Anzeigegröße von Zeichenketten

You never know how much space a string will take on screen when translated. It might very possibly be twice the size of the original English string. Luckily, most gtkmm widgets will expand at runtime to the required size.

27.4.4. Unübliche Wörter

Sie sollten kryptische Abkürzungen, Slang oder Jargon vermeiden. So etwas ist recht schwierig zu übersetzen und oft selbst für Muttersprachler nur schwer verständlich. Beispielsweise sollten Sie »application« gegenüber »app« bevorzugen.

27.4.5. Verwendubg von Nicht-ASCII-Zeichen in Zeichenketten

Currently, gettext does not support non-ASCII characters (i.e. any characters with a code above 127) in source code. For instance, you cannot use the copyright sign (©).

To work around this, you could write a comment in the source code just before the string, telling the translators to use the special character if it is available in their languages. For english, you could then make an American English en_US.po translation which used that special charactger.