[Interest] Translating plural with is/are

André Somers andre at familiesomers.nl
Mon Mar 7 20:30:06 CET 2016



Op 07/03/2016 om 20:25 schreef André Somers:
>
>
> Op 07/03/2016 om 19:56 schreef Jason H:
>>> If you provide a translation file, the message with %n will be 
>>> translated
>>> according to the language's plural rules. For English, you'll have two
>>> translations for the same source message.
>>>
>>>     "At least one upper case character is required" (a)
>>>     "At least %n upper case characters are required" (b)
>>>
>>> QTranslator takes care to apply the correct selection based on the 
>>> number that
>>> you passed.
>> Ok I'm getting there, but how do I specify this string (a) or that 
>> string (b)?
>> What's the qsTr() line look like?
>> qsTr( ?
> It doesn't matter how your string inside the tr or qsTr looks, as long 
> as it contains the %n. It is useful for both developers and 
> translators if it looks roughly like the string you want out of it but 
> that is not strictly needed. You could just make due with 
> qsTr("MESSAGE_UPPER_CASE_CHARACTERS %n", n) or something like that 
> though I personaly don't like this. It is up to the person filling the 
> translation file with translations (including the one for English) to 
> make sure that both versions of the definitive string are provided in 
> the .ts file.
>
> André
By the way, note that using "one" literally in your translation will 
trigger a warning, as the %n is missing in the translated string. Though 
there are good reasons for it as I understand it, I find that annoying 
but that's how it is.

André




More information about the Interest mailing list