New i18n interface for KDE 4

Chusslove Illich caslav.ilic at gmx.net
Thu Sep 15 21:53:10 BST 2005


>> [: Michael Olbrich :]
>> const char *msg = "Blah, blah: %1";
>> ...
>> i18n(msg, foo);
>
> [: Nicolas Goutte :]
> That does not work with the patched xgettext that KDE uses, not even if
> you would define the text in the i18n call.
>
> This could however work with a normal xgettext (with the text defined
> in the call), as some of the Gettext functions are printf-like. [...]

Actually, it wouldn't. For unpatched Gettext to work with any system, there 
would have to be no context info call, which is, I think, not acceptable.

So, the second idea (of Stephan Kulow) is to have a little script which 
would temporary rewrite i18n() calls, in such way that unpatched xgettext 
can process it.

In the case of template i18n() functions, it would go like this:

i18n("Blah, blah: %1 %2", a, b)
transforms into:
i18n(gettext("Blah, blah: %1 %2"), a, b)

i18nc("Translators...", "Blah, blah: %1 %2", a, b)
transforms into:
i18nc(gettext("_: Translators...\nBlah, blah: %1 %2"), a, b)

i18np("%n file in folder %1", "%n files in folder %1", n, f)
transforms into:
i18np(gettext("_n: %n file in folder %1\n%n files in folder %1"), n, f)
or, if we switch to gettext plurals in PO files:
i18np(ngettext("%n file in folder %1", "%n files in folder %1", n), n, f)

Again, transformation is just temporary, executed the moment before 
unpatched xgettext is run, and afterwards discarded. It seems to me that 
such script wouldn't be hard to write.

---

Now that I think more, with this template solution it would be easier to 
make this one nasty mistake. At first, you use bare i18n() call:

i18n("None")

and afterwars you decide to add context info:

i18n("No actions present", "None")

but *forget* to change call to i18nc(). This would result in application 
showing "No action present" instead of "None".

Though, again we could flash warnings or aborts (as there are zero 
placeholders, and one argument given), and that transformation script 
could also do some checks...

-- 
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/20050915/3c2a1c95/attachment.sig>


More information about the kde-core-devel mailing list