KLocalizedString regression

John Tapsell johnflux at gmail.com
Fri Mar 25 14:21:06 GMT 2011


On 25 March 2011 13:59, John Tapsell <johnflux at gmail.com> wrote:
> On 25 March 2011 13:19, Chusslove Illich <caslav.ilic at gmx.net> wrote:
>>> [: John Tapsell :]
>>> If the number is small, I want to show "2 seconds" but if it's large I
>>> want like "2.2e4" seconds.
>>>
>>> You're saying that my API needs to require the user to now pass *two*
>>> strings for that?
>>
>> Well, yes. Two grammar-wise different text fragments (enumerable vs.
>> measurable quantities) are being used in alternation, so each should be
>> represented by its own string. The author of KUnitConversion wanted the same
>> feature, so there too we ended up defining two strings, e.g:
>>
>>      setDefaultUnit(UP(Meter, 1,
>>        ...
>>        ki18nc("amount in units (real)", "%1 meters"),
>>        ki18ncp("amount in units (integer)", "%1 meter", "%1 meters")
>>      ));
>
> Except that in my case, I'm forcing this on the users of my API.  Just
> to get around this!
>
> Can't you see how crazy this is?
>
>> In my opinion, however, this alternation is bad style-wise. The display
>> should use either the measurable form throughout (2.0 seconds; 2.2e4
>> seconds), or the enumerable form throughout (2 seconds; 6 hours 6 minutes).
>
> But what if I want to allow both?  This is for labelling the axis of a
> graph.  I now have to have an API and forces the users to give the
> same string twice.


Chusslove, I just had an idea - so okay, if I'm forced to work around
this feature, could I do:

string.remove("(I18N_PLURAL_ARGUMENT_MISSING)");

This string won't change, and isn't translated right?

John




More information about the kde-core-devel mailing list