Removing %n in plural i18n calls

Krzysztof Lichota krzysiek at lichota.net
Sun Feb 11 17:15:32 GMT 2007


Chusslove Illich napisaƂ(a):
> For some time I wanted to propose removal of special %n placeholder in 
> plural *i18np, *i18ncp calls. Instead, only ordinary numbered placeholders 
> are to be used, and the first integer-valued one determines the plural 
> form.
> 
> I believe %n to be unnecessary, legacy element of i18n API. All-numbered 
> placeholders would mean that all strings could be recognized by Gettext as 
> qt-format, and we would thus get Gettext's checks working (though 
> qt-format in Gettext is a bit out of date, but that is a matter of having 
> it patched upstream).
> 
> There was also a discussion on kde-i18n-doc some months ago, you can take a 
> look for reference: 
> http://lists.kde.org/?l=kde-i18n-doc&m=115197256218486&w=2 (note that 
> there I proposed %1 to always determine plural, whether now it's first 
> integer-valued placeholder).
> 
> As another streamlining, I've also decided to disallow gaps in placeholders 
> sequence, ie. i18n("Blah %1 blah %3 blah", ...) would no longer be legal. 
> I originally kept it by inertia from QString, but QString probably needs 
> it only because its single-argument arg() methods operate one after 
> another, so each next application doesn't see the previous placeholder.
> 
> Taken together, if you now wonder whether this is still legal:
> 
> i18np("One file in folder %2", "%1 files in folder %2", nfiles, folder)
> 
> yes it is, because the placeholder corresponding to plural argument is 
> excepted from sequence rule, it is allowed to be missing in either 
> singular or plural.

Wouldn't it be better to get rid of i18np() at all and make plurals
detection automatic? I mean that if argument is integer, it would be
automatically possible to use plural (it can be done by overloading
arg(int) method). This way developers would not have to even know about
special handling of plurals. For example:
i18n("%1 files were moved").arg(numFiles)

arg(int) would check if msgstr for i18n("%1 files were moved") contains
plural form and if so, it would apply its argument to proper plural form.

I think it would make life easier for developers (no need to remember to
put plurals) and for translators (we don't have to report bugs when
plural form is not used, just make the msgstr plural).

	Krzysztof Lichota (Polish translation team)



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070211/467e1cb2/attachment.sig>


More information about the kde-core-devel mailing list