Finalized proposal for changes to i18n in KF5

David Faure faure at kde.org
Wed Dec 26 17:10:59 GMT 2012


On Saturday 22 December 2012 10:44:22 Chusslove Illich wrote:
> I have written up the headers and Doxygen pages for the Ki18n framework as
> it should finally look like, available here:
> 
>   http://nedohodnik.net/misc/ki18n-kf5-01/html/index.html
>   http://nedohodnik.net/misc/ki18n-kf5-01/klocalizedstring.h
>   http://nedohodnik.net/misc/ki18n-kf5-01/kuitmarkup.h

Nice writeup, very complete!

> The first change is that every i18n call looks up translations in strictly
> one catalog, which is even determined statically in library code (i.e. at
> compile time). This will stop undefined results when several catalogs in use
> contain the same message. The section "Connecting Calls to Catalogs" in the
> documentation above shows how to make the link.

#define TRANSLATION_CATALOG "foolib"
#include <klocalizedstring.h>

The goal is very sound (looking up messages in only one .po file, that must be 
good for performance, too). The #define will kill any "enable final" compilation 
support, but then again I think this is gone anyway.

>    #define i18n(...) i18nd(TRANSLATION_CATALOG, __VA_ARGS__)

Is this portable to all compilers supported by KDE?


BTW, something else I spotted:
    KLocalizedString subs (QChar a, int fieldWidth = 0,
                           const QChar &fillChar = QLatin1Char(' ')) const;
See how one QChar is passed by value, and the other by const ref?
QChar is just a ushort, so it should be passed by value everywhere, as per
http://www.macieira.org/blog/2012/02/the-value-of-passing-by-value/

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20121226/750ec154/attachment.sig>


More information about the kde-core-devel mailing list