Finalized proposal for i18n in KF5, second iteration
Chusslove Illich
caslav.ilic at gmx.net
Mon May 20 17:25:45 UTC 2013
> [: Oswald Buddenhagen :]
> as for the TRANSLATION_DOMAIN define, that really should come from the
> build system to start with.
I have nothing against that, but a there must be a way which is independent
of the build system. It would seem bizare to me that one could not, for
example, write a single-file program and build it directly with single
compiler invocation, and have i18n working too.
And I actually don't have an idea how one would do this with a build system
in a cleaner way.
> it's always a bad idea to use defines which configure headers in the
> sources themselves (you run into include order problems really quickly).
Maybe I should strenghten that point in the doc, but the idea (talking about
a public header) is that TRANSLATION_DOMAIN plus inclusion is done only
where necessary, and cancelled as soon as not necessary. For example, what
would be the problem with:
#ifndef SOMEHEADER_H
#define SOMEHEADER_H
#include <foo.h>
#include <bar.h>
#include <klocalizedstring.h> // for whatever ordinary functionality
#include <qwyx.h>
// some code
#define TRANSLATION_DOMAIN "blurb"
#include <klocalizedstring.h>
// some code with i18n calls, no includes in between
#undef TRANSLATION_DOMAIN
#include <klocalizedstring.h>
// some code
#endif
Of course, the assumption is that foo.h, bar.h, etc. also did this where
necessary, leaving a clean macro environment behind themselves.
> fwiw, this also means that the trick suggested at the bottom of
> klocalizedstring.h is not such a great idea (and to start with, to avoid
> that the preprocessor floods you with redefinition warnings, the #undefs
> have to come first, unconditionally).
I think that redefinition warnings are the good thing to have here, as
otherwise a wrongly placed include would silently clobber the outer
environment:
#ifndef SOMEHEADER_H
#define SOMEHEADER_H
#define TRANSLATION_DOMAIN "blurb"
#include <klocalizedstring.h>
#include <foo.h>
#include <bar.h> // also does TRANSLATION_DOMAIN thingy
#include <qwyx.h>
// some code, i18n calls here silently clobbered
#undef TRANSLATION_DOMAIN
#include <klocalizedstring.h>
#endif
--
Chusslove Illich (Часлав Илић)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20130520/f13983b9/attachment.sig>
More information about the Kde-frameworks-devel
mailing list