Translating a piece of software can generally lead to different kinds of desasters. German and French users might remember one of the greatest failures in computer history regarding quality of text: Civilization by Sid Meier. Anyway, how do you reach both goals: A clean, flexible and grammatical correct language file which is also free from redundancies?
1. the dilemma
Image a software which prints out the number of articles in its database. The result could be “Currently, there are 5 articles in the database”.
The current solution in the english language file is as follows:
$msgHomeThereAre = “There are “;
$msgHomeArticlesOnline = ” records online”;
This is highly dangerous. Image a situation where only on article is online, a template with “$msgHomeThereAre, $number_of_records, $msgHomeArticlesOnline” would look like:
There are 1 records online
(If your phpMyFAQ only contains one article, a broken sentence is the least thing you should worry about)
I do not speak many languages and most of them are in the same family, so I have no idea if this problem will be in other languages. One thing I should assume is (Hey Murphy!):
Any static rule how to form sentences with variable content will fail.
English speakers will know the singular (one stone) and the plural (many stones). The way the plural is created appears to be pretty simple by just adding one s. However, even in English, this rule will fail if you neglect the exceptions (one story, many stories).
German, for example is even worse: Ein Baum (one tree), viele B?ume (many trees). Notice the ‘umlaut‘ dots over the first vowel? Ein Kaktus (one cactus), viele Kakteen (many cactuses/cacti).
At least the classic Semitic languages feature another thing: the dual (two books).
Many languages do not have any problem with “No.” as a full sentence. So no matter what the question was (“do you want to delete that record?”) or (“do you want to resume?”) , one entry with $msgNo will be okay. Now, how do you deal with languages which do not allow such simple constructions and require to repeat the question? Following the first thought, you will end up in dozens of language file entries like
$msgDeleteNo = “No.”;
$msgResumeNo = “No.”;
$msgPostingNo = “No.”;.
This is horrible.
2. A solution?
I haven’t tried this out yet, I’m sure I’ll run into problems and I doubt that it will prevent me from a situation where the sentence will be wrong under extreme circumstances – but this might be a fair-enough solution:
Nesting.
A file which is able to store language-specific necessities. (Please ignore all the syntax related things, this is not a real language.)
english.php
$msgHomeArticlesOnline = “There %b %a %c online”;
%a:{$NumArticlesOnline}
%b: case %a/1 = “is” else “are”;
%c: case %a/1 = “record” else “records”;
german.php
$msgHomeArticlesOnline = “Es %b %a %c online”;
%a:{$NumArticlesOnline}
%b: case %a/1 = “ist” else “sind”;
%c: case %a/1 = “Eintrag” else “Eintr?ge”;
and so on. Any comments on that?