[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Use I18n file of other program
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2011-07-25 8:41:04
Message-ID: 201107251041.08802.caslav.ilic () gmx ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


> [: Weng Xuetian :]
> I need to load the existing translation of this input method and use it
> KCM Module, and KDE's i18n series function seems not to have support like
> gettext's dgettext (google result says that). Should I use dgettext
> directly here?

The short answer is yes, use dgettext() directly. It should work as usual,
only remember to put somewhere bindtextdomain() call and configure its
locale dir path at build.

As for KDE i18n, there is also the ki18n() series, which enables explicit
selection of domain:

  QString trmsg = ki18n("...").toString("foodomain");

But, KDE i18n puts some constraints on messages, like expecting them to be
well-formed XML strings. So it should only be used to fetch messages from
native KDE catalogs.

> And another question.. How does KDE determine which Gettext file to use?
> The same with the value specified in KAboutData ?

Default calls (those not having that .toString(domain) above) look for the
translation through all loaded catalogs within the process. Catalogs are
loaded either by being specified in KAboutData, or by explicitly calling
KLocale::global()->insertCatalog().

This was (in my opinion) a design mistake, since it can cause, and does
cause in practice, wrong translation from underlying libraries to be fetched
in a random app. It will hopefully be rectified in some future rehaul of KDE
i18n API.

-- 
Chusslove Illich (Часлав Илић)

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic