[Development] [Interest] Direct-lookup translation, even for English (was Re: get english translation)
André Somers
andre at familiesomers.nl
Wed Sep 3 09:15:26 CEST 2014
Kobus Jaroslaw schreef op 3-9-2014 08:25:
>> Actually, some of the i18n features of Qt _requires_ you to provide an English translation.
>> This is the case for the plural forms, where the engineer typically writes.
>> tr("Found %n item(s)", 0, m_numberOfItemsFound);
>> And Qt will pick the singular/plural translation (that came from the translation file)
>> depending on the value of m_numberOfItemsFound.
> Can't we just provide some tr() overload, in which you could also specify plural and paucal forms in source code, next to the number? E.g.
>
> tr("Found %n item" /*singular*/, "Found %n items" /*paucal*/, "Found %n items" /*plural*/, m_numberOfItemsFound);
>
> In this way the English in the source code could be good enough.
>
I hope not.
It's rather trival to do this using a translation file. A simple search
in Linguist will find all these occurrences.
If you really don't want to use that, you could also just provide two
strings in code just for English (or whatever your base language is):
if (m_numberOfItemsFound == 1) {
.... tr("Found 1 item");
} else {
.... tr("Found %n items", "", m_numberOfItemsFound);
}
André
More information about the Development
mailing list