Translating texts from the kernel / Soundcard control names in KMix (good one)

Christian Esken esken at
Wed Aug 19 10:08:29 BST 2009

Am Dienstag 18 August 2009 23:40:23 schrieben Sie:
> A Dimarts, 18 d'agost de 2009, Christian Esken va escriure:

Thanks for the detailed answer, Albert.

I will work on converting my code to that. The label translation could then 
use exactly the same infrasructure (comments below).

> > 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)

> >    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").


> msgid "Mic"
> msgstr "Aufnahmestärke des Mikrophoneingangs"
> is WRONG in a .po file, as "Aufnahmestärke des Mikrophoneingangs" is not
>  the translation of "Mic"

Well, you can't say it is wrong, it is just unusual. The PO format doesn't 
define the semantics you describe. Actually in PO files the "msgid" is just an 
ID. So it could be anything: Numbers, hashcodes, a chinese text.

The point is, that I don't know the english text. I only receive the ID from 
the kernel.  Not straightforward, but I can follow your suggestion below.

> 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 ....
> }

OK. In that case, the "msgid" keys are so long that they won't collide with 
other translations.

> > 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.

Yes, I already guessed so. :-)

> Once you have that kernelWhatsthis.cpp file you can put inside a controls/
> directory and then change your [...]

> Albert
> P.S: If you "know" the readableNames you are going to get maybe it would be
>  a good idea to provide translated labels for things like "Master", that
>  would be as easy as creating a
> QString translateKernelToName(const QString &kernelName)
> {
> 	if (kernelName == "Master") return i18nc("The Master channel of the sound
> card", "Master");
>     else if ....
> }

Yes, labels would be next. I think the context could be quite short/identical 
for all controls like this:
if [...] return i18nc("Channel Translation", "Master");
if [...] return i18nc("Channel Translation", "PCM");
if [...] return i18nc("Channel Translation", "CD");

I think the translateKernelToName() method could go in the same  controls/ 
directory, like this:

controls/WhatsThis.cpp   # WhatThis for the controls
controls/ControlLabels.cpp   # Labels the controls


> and when creating the labels doing
> QString name = md->readableName();
> label->setText(translateKernelToName(name));
> > Greetings,
> >     Christian

More information about the kde-core-devel mailing list