diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-12-11 03:46:01 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-12-11 03:46:01 +0000 |
commit | 865f314dd5ed55508f45a32973b709b79a541e36 (patch) | |
tree | dc1a3a884bb2fc10a89a3c46313897d22c5771eb /kdecore/kconfigbackend.cpp | |
parent | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (diff) | |
download | tdelibs-865f314dd5ed55508f45a32973b709b79a541e36.tar.gz tdelibs-865f314dd5ed55508f45a32973b709b79a541e36.zip |
kdelibs update to Trinity v3.5.11
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1061230 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/kconfigbackend.cpp')
-rw-r--r-- | kdecore/kconfigbackend.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/kdecore/kconfigbackend.cpp b/kdecore/kconfigbackend.cpp index 37bafdced..153b9aa1a 100644 --- a/kdecore/kconfigbackend.cpp +++ b/kdecore/kconfigbackend.cpp @@ -505,6 +505,8 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1()); bool fileOptionImmutable = false; bool groupOptionImmutable = false; bool groupSkip = false; + bool foundGettextDomain = false; + QCString gettextDomain; int line = 0; for(; s < eof; s++) @@ -596,6 +598,7 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1()); if (groupSkip && !bDefault) goto sktoeol; // Skip entry + bool optionImmutable = groupOptionImmutable; bool optionDeleted = false; bool optionExpand = false; @@ -695,6 +698,11 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1()); QCString val = printableToString(st, s - st); //qDebug("found key '%s' with value '%s'", key.data(), val.data()); + if (QString(key.data()) == "X-Ubuntu-Gettext-Domain") { + gettextDomain = val.data(); + foundGettextDomain = true; + } + KEntryKey aEntryKey(aCurrentGroup, decodeKey(key)); aEntryKey.bLocal = (locale != 0); aEntryKey.bDefault = bDefault; @@ -718,6 +726,34 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1()); pConfig->putData(aEntryKey, aEntry, false); } } + // Look up translations using KLocale + // https://launchpad.net/distros/ubuntu/+spec/langpacks-desktopfiles-kde + // This calls KLocale up to 10 times for each config file (and each KConfig has up to 4 files) + // so I'll see how much of a performance hit it is + // it also only acts on the last group in a file + // Ideas: only translate most important fields, only translate "Desktop Entry" files, + // do translation per KConfig not per single file + if (!pWriteBackMap) { + QFile file("file.txt"); + if (foundGettextDomain) { + + KLocale locale(gettextDomain); + + QString language = locale.language(); + translateKey(locale, aCurrentGroup, QCString("Name")); + translateKey(locale, aCurrentGroup, QCString("Comment")); + translateKey(locale, aCurrentGroup, QCString("Language")); + translateKey(locale, aCurrentGroup, QCString("Keywords")); + translateKey(locale, aCurrentGroup, QCString("About")); + translateKey(locale, aCurrentGroup, QCString("Description")); + translateKey(locale, aCurrentGroup, QCString("GenericName")); + translateKey(locale, aCurrentGroup, QCString("Query")); + translateKey(locale, aCurrentGroup, QCString("ExtraNames")); + translateKey(locale, aCurrentGroup, QCString("X-KDE-Submenu")); + } + } + + if (fileOptionImmutable) bFileImmutable = true; @@ -732,6 +768,21 @@ qWarning("SIGBUS while reading %s", rFile.name().latin1()); #endif } +void KConfigINIBackEnd::translateKey(KLocale& locale, QCString currentGroup, QCString key) { + KEntryKey entryKey = KEntryKey(currentGroup, key); + KEntry entry = pConfig->lookupData(entryKey); + if (QString(entry.mValue) != "") { + QString orig = key + "=" + entry.mValue; + QString translate = locale.translate(key + "=" + entry.mValue); + if (QString::compare(orig, translate) != 0) { + translate = translate.mid(key.length() + 1); + entry.mValue = translate.utf8(); + entryKey.bLocal = true; + entry.bNLS = true; + pConfig->putData(entryKey, entry, false); + } + } +} void KConfigINIBackEnd::sync(bool bMerge) { |