Translating texts from the kernel / Soundcard control names in KMix

Oswald Buddenhagen ossi at kde.org
Sat Sep 5 09:07:04 BST 2009


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






More information about the kde-core-devel mailing list