New i18n interface for KDE 4, second try

Chusslove Illich caslav.ilic at gmx.net
Sat Oct 29 11:51:58 BST 2005


>> [: Chusslove Illich :]
>> i18n("Blah, blah: %1 %2", foo, bar);
>> [...]
>> Since this template is defined inline, and is simple enough, compiler
>> will inline it, so the original call will be compiled as:
>>
>> KTrString("Blah, blah: %1 %2").arg(foo).arg(bar).toString();
>
> [: Nicolas Goutte :]  
> Remains one case: what if the parameter is too of kind KTrString?

Doesn't compile. Only types which arg() methods of QString would support 
are possible. But, if you had in mind something like:

i18n("Blah, blah: %1 %2", i18n("Foo"), bar);

that would not be a problem, as i18n does return a QString (it is that 
ki18n() that would return a KAlbatrossString, for rare circumstances when 
it is needed).

> [...] sometimes the string has % in it and it should not be replaced.
> (That is why there are the QString::arg with multiple QString to avoid
> that a %2 in the first argument is replaced by the second argument.)

This is one of the special circumstances where ki18n would be needed. One 
could use simply:

ki18n("Blah, blah: %1 %2").arg(foo, bar).toString();

Throughout base KDE packages, I've encountered 130 i18n calls with .arg() 
methods with more than one argument (and hence, they are not converted to 
template i18n(...) form, but to ki18n(...)...toString() form).

>> [: Chusslove Illich :]
>> For example, when giving context, if they forget to specify correct
>> call name:
>>
>> i18n("This is entry in menu Session", "New");
>>
>> the result would be that in runtime it shows "This is entry in menu
>> Session" instead of "New" :) And a warning message about too many
>> parameters would appear in the shell output.
>
> [: Nicolas Goutte :]  
> Yes, but it is not as good...
> [...]
> ...especially for plural form, as the singular is a valid value.

Ugh, that is nasty. Anybody has a way around (robust check), or back to the 
drawing board? :)

-- 
Chusslove Illich (Часлав Илић)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20051029/cee62247/attachment.sig>


More information about the kde-core-devel mailing list