To create an extensible PHP content management system , language translations are crucial. I studied software approaches to the translation system, and I thought that Qt Linguist is a good example.
This is an example usage from the Qt documentation:
int n = messages.count(); showMessage(tr("%n message(s) saved", "", n));
Qt uses well-known language rules to determine if " message " " s " is in English.
When I brought this example to my development team, they discovered a problem that jeopardizes the extensibility of Qt tr() function modeling.
This is a similar example, except that now something is seriously wrong.
int n = deadBacteria.count(); showMessage(tr("%n bacterium(s) killed", "", n));
The set of " bacterium " is equal to " bacteria ". Incorrectly add " s ".
I do not have much experience with Qt Linguist, but I have not seen how it handles irregular conjugations and forms.
A more complex phrase might be "%n cactus(s) have grown." . The plural must be " cactii " and " have " must be conjugated with " has " if there is one cactus.
You might think that a logical correction is to avoid these irregular words because they are not used in programming. Well, this is not useful in two ways:
- Perhaps there is a language that changes nouns irregularly, although the source string works in English, for example,
"%n message(s) saved" . In MyImaginaryLanguage, the correct way to form the translated string could be "1Message saved", "M2essage saved", "Me3ssage saved" for %n values 1 , 2 and 3 , respectively, and it doesn Look like Qt Linguist has rules for this. - To make CMS extensible as I need to be mine, all types of web applications need to be considered. Someone can create a role-playing game that requires proposals to be built as "5 cacti." Or maybe the security software wants to say: "ClamAV detected 2 viruses." unlike "ClamAV detected 2 viruses."
After searching the Internet to find out if other Qt developers have a solution to this problem, and without finding any, I came to Stack Overflow.
I want to know:
- What extensible and efficient programming method should be used to translate strings with possible irregular rules?
- What do Qt programmers and translators do if they face this unevenness problem?