Next: Split at paragraphs, Previous: Decent English style, Up: Preparing Translatable Strings [Contents][Index]
Translatable strings should be entire sentences. It is often not possible to translate single verbs or adjectives in a substitutable way.
printf ("File %s is %s protected", filename, rw ? "write" : "read");
Most translators will not look at the source and will thus only see the
string "File %s is %s protected"
, which is unintelligible. Change
this to
printf (rw ? "File %s is write protected" : "File %s is read protected", filename);
This way the translator will not only understand the message, she will also be able to find the appropriate grammatical construction. A French translator for example translates "write protected" like "protected against writing".
Entire sentences are also important because in many languages, the declination of some word in a sentence depends on the gender or the number (singular/plural) of another part of the sentence. There are usually more interdependencies between words than in English. The consequence is that asking a translator to translate two half-sentences and then combining these two half-sentences through dumb string concatenation will not work, for many languages, even though it would work for English. That’s why translators need to handle entire sentences.
Often sentences don’t fit into a single line. If a sentence is output
using two subsequent printf
statements, like this
printf ("Locale charset \"%s\" is different from\n", lcharset); printf ("input file charset \"%s\".\n", fcharset);
the translator would have to translate two half sentences, but nothing
in the POT file would tell her that the two half sentences belong together.
It is necessary to merge the two printf
statements so that the
translator can handle the entire sentence at once and decide at which
place to insert a line break in the translation (if at all):
printf ("Locale charset \"%s\" is different from\n\ input file charset \"%s\".\n", lcharset, fcharset);
You may now ask: how about two or more adjacent sentences? Like in this case:
puts ("Apollo 13 scenario: Stack overflow handling failed."); puts ("On the next stack overflow we will crash!!!");
Should these two statements merged into a single one? I would recommend to
merge them if the two sentences are related to each other, because then it
makes it easier for the translator to understand and translate both. On
the other hand, if one of the two messages is a stereotypic one, occurring
in other places as well, you will do a favour to the translator by not
merging the two. (Identical messages occurring in several places are
combined by xgettext
, so the translator has to handle them once only.)
Next: Split at paragraphs, Previous: Decent English style, Up: Preparing Translatable Strings [Contents][Index]