Translating texts from the kernel / Soundcard control names in KMix
Albert Astals Cid
aacid at kde.org
Tue Aug 18 22:33:49 BST 2009
A Dimarts, 18 d'agost de 2009, Christian Esken va escriure:
> Hello,
>
> I am currenlty adding WhatsThis help to the KMix controls. This is kind of
> special i18n usage, as the message ID's cannot be extraacted from the
> source, but are coming directly from the kernel (e.g. "Master", or "PCM
> Path Out & Mute").
>
> I'd like some comments about the concept:
>
> 1) Is it a good idea to use a separate message/po file for that?
> As we have 2 different sources, it sounds reasonable to me.
It's reasonable yes
> 2) Implementation (revision 1013107)
> After reading the docs, i came up with the following code:
>
>
> // Locale created once (static). Used below by
> whatsthisControlLocale() s_whatsthisLocale = new KLocale("kmix-controls");
>
> // ...
>
> QString w;
> QString whatsthis (md->readableName());
> char* whatsThisChar = whatsthis.toUtf8().data();
> w = ki18n(whatsThisChar).toString(MixerToolBox::whatsthisControlLocale()
> ); setWhatsThis(w);
>
>
> Is that OK? I have a problem that the first translated message is garbage /
> contains random characters. The rest is OK, even when using the same
> message id as the garbage message.
No, it's wrong. To add the "kmix-controls" catalog just go with
KGlobal::locale()->insertCatalog("kmix-controls").
Also your use of .po files is wrong, you don't use them as a key value file, i
mean
msgid "Mic"
msgstr "Aufnahmestärke des Mikrophoneingangs"
is WRONG in a .po file, as "Aufnahmestärke des Mikrophoneingangs" is not the
translation of "Mic"
the file should be
msgstr "Recording level of the microphone input."
msgstr "Aufnahmestärke des Mikrophoneingangs"
And the english file should not exist, since you don't need to translate
english to english ;-)
My suggestion is that you create a file called something like
kernelWhatsthis.cpp with a function that does
QString translateKernelToWhatsthis(const QString &kernelName)
{
if (kernelName == "Mic") return i18n("Recording level of the microphone
input.");
else if ....
}
and then you just do setWhatsThis(translateKernelToWhatsthis(md-
>readableName());
>
>
> 3) How would this be integrated in the build/installation process?
> I have placed a l10n/ directory with the message files below kmix/. Is it
> good there or should that be moved somewhere else.
No, that sucks. Noone is going to translate this as it's totally out of our
i18n procedure.
Once you have that kernelWhatsthis.cpp file you can put inside a controls
directory and then change your Messages.sh to
#! /bin/sh
$XGETTEXT *.cpp -o $podir/kmix.pot
>
>
> Greetings,
> Christian
More information about the kde-core-devel
mailing list