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

List:       kde-core-devel
Subject:    Re: Translating texts from the kernel / Soundcard control names in
From:       Oswald Buddenhagen <ossi () kde ! org>
Date:       2009-09-05 8:07:04
Message-ID: 20090905080704.GA2309 () ugly ! local
[Download RAW message or body]

On Tue, Aug 18, 2009 at 11:33:49PM +0200, Albert Astals Cid wrote:
> 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 ....
> }
> 
that's everything but elegant, especially when the number of names
gets rather big. consequently christian's data-driven approach is much
better, though a .po file might not be the right format. i think a
kconfig file would be a good solution; the extraction of messages from
these has already been solved as well (some minor adaptations might be
needed).

if hard-coding into the source code as such is acceptable at all, then
it should be done with a static array:

static const struct {
   const char const *kernelName, *fullName;
} nameMapInit[] = {
  { "Mic.", I18N_NOOP("Recording level of the microphone input.") },
  ...
};

QHash nameMap;
for (int i = 0; i < sizeof(nameMapInit)/sizeof(nameMapInit[0]); i++)
   nameMap.insert(QString::fromUtf8(nameMapInit[i].kernelName),
                  i18n(nameMapInit[i].fullName));


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

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