File desktop-translations.diff of Package kdelibs4

--- kdecore/config/kconfig.cpp
+++ kdecore/config/kconfig.cpp
@@ -754,6 +754,17 @@
     return entryMap.getEntry(group, key, QString(), flags, expand);
 }
 
+QByteArray KConfigPrivate::lookupExactData(const QByteArray& group, const char* key,
+                                      KEntryMap::SearchFlags flags) const
+{
+    if (bReadDefaults)
+        flags |= KEntryMap::SearchDefaults;
+    const KEntryMapConstIterator it = entryMap.findExactEntry(group, key, flags);
+    if (it == entryMap.constEnd())
+        return QByteArray();
+    return it->mValue;
+}
+
 void KConfig::virtual_hook(int /*id*/, void* /*data*/)
 {
 	/* nothing */
--- kdecore/config/kconfigdata.h
+++ kdecore/config/kconfigdata.h
@@ -175,6 +175,19 @@
             return find(theKey);
         }
 
+        ConstIterator findExactEntry(const QByteArray& group, const QByteArray& key = QByteArray(),
+                           SearchFlags flags = SearchFlags()) const
+        {
+            KEntryKey theKey(group, key, false, bool(flags&SearchDefaults));
+
+            // try the localized key first
+            if (flags&SearchLocalized) {
+                theKey.bLocal = true;
+                return find(theKey);
+            }
+            return find(theKey);
+        }
+
         Iterator findEntry(const QByteArray& group, const QByteArray& key = QByteArray(),
                            SearchFlags flags = SearchFlags())
         {
--- kdecore/config/kconfiggroup.cpp
+++ kdecore/config/kconfiggroup.cpp
@@ -1239,6 +1239,16 @@
     return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
 }
 
+bool KConfigGroup::hasTranslatedKey(const char* key) const
+{
+    Q_ASSERT_X(isValid(), "KConfigGroup::hasTranslatedKey", "accessing an invalid group");
+
+    KEntryMap::SearchFlags flags = KEntryMap::SearchLocalized;
+    if ( config()->readDefaults() )
+        flags |= KEntryMap::SearchDefaults;
+    return !config()->d_func()->lookupExactData(d->fullName(), key, flags).isNull();
+}
+
 bool KConfigGroup::hasKey(const QString &key) const
 {
    return hasKey(key.toUtf8().constData());
--- kdecore/config/kconfiggroup.h
+++ kdecore/config/kconfiggroup.h
@@ -617,6 +617,11 @@
      */
     QMap<QString, QString> entryMap() const;
 
+    /**
+     * @internal
+     */
+    bool hasTranslatedKey( const char *pKey ) const;
+
 protected:
     bool hasGroupImpl(const QByteArray &group) const;
     KConfigGroup groupImpl(const QByteArray &b);
--- kdecore/config/kconfig_p.h
+++ kdecore/config/kconfig_p.h
@@ -53,6 +53,7 @@
     QString lookupData(const QByteArray& group, const char* key, KEntryMap::SearchFlags flags,
                        bool* expand) const;
     QByteArray lookupData(const QByteArray& group, const char* key, KEntryMap::SearchFlags flags) const;
+    QByteArray lookupExactData(const QByteArray& group, const char* key, KEntryMap::SearchFlags flags) const;
 
     void putData(const QByteArray& group, const char* key, const QByteArray& value,
                  KConfigBase::WriteConfigFlags flags, bool expand=false);
--- kdecore/config/kdesktopfile.cpp
+++ kdecore/config/kdesktopfile.cpp
@@ -35,6 +35,8 @@
 #include "kstandarddirs.h"
 #include "kconfigini_p.h"
 #include "kde_file.h"
+#include "kcatalog_p.h"
+#include "klocale.h"
 
 class KDesktopFilePrivate : public KConfigPrivate
 {
@@ -179,6 +181,34 @@
   return false;
 }
 
+QString KDesktopFile::translatedEntry(const char* key) const
+{
+  Q_D(const KDesktopFile);
+  return translatedEntry( d->desktopGroup, key );
+}
+
+QString KDesktopFile::translatedEntry(const KConfigGroup& group, const char* key) const
+{
+  if (group.hasTranslatedKey(key))
+    return group.readEntry(key);
+
+  if (group.hasKey(key)) {
+    QString value = group.readEntryUntranslated(key);
+    QString fName = fileName();
+    fName = fName.mid(fName.lastIndexOf('/')+1);
+    QString po_lookup_key = QString::fromLatin1(key) + "(" + fName + "): " + value;
+    QString po_value;
+    KGlobal::locale()->translateRaw(po_lookup_key.toUtf8().data(), NULL, &po_value);
+
+    if (po_value == po_lookup_key)
+      return value;
+
+    return po_value;
+  }
+
+  return QString::null;
+} 
+
 QString KDesktopFile::readType() const
 {
   Q_D(const KDesktopFile);
@@ -193,20 +223,17 @@
 
 QString KDesktopFile::readName() const
 {
-  Q_D(const KDesktopFile);
-  return d->desktopGroup.readEntry("Name", QString());
+  return translatedEntry("Name");
 }
 
 QString KDesktopFile::readComment() const
 {
-  Q_D(const KDesktopFile);
-  return d->desktopGroup.readEntry("Comment", QString());
+  return translatedEntry("Comment");
 }
 
 QString KDesktopFile::readGenericName() const
 {
-  Q_D(const KDesktopFile);
-  return d->desktopGroup.readEntry("GenericName", QString());
+  return translatedEntry("GenericName");
 }
 
 QString KDesktopFile::readPath() const
--- kdecore/config/kdesktopfile.h
+++ kdecore/config/kdesktopfile.h
@@ -243,6 +243,11 @@
 
   const char *resource() const;
 
+  /**
+   * @internal SUSE addition
+   */
+  QString translatedEntry(const KConfigGroup& group, const char*) const;
+
 protected:
   /** Virtual hook, used to add new "virtual" functions while maintaining
       binary compatibility. Unused in this class.
@@ -250,6 +255,8 @@
 //  virtual void virtual_hook( int id, void* data );
 private:
 
+  QString translatedEntry(const char*) const;
+
   Q_DISABLE_COPY(KDesktopFile)
 
   Q_DECLARE_PRIVATE(KDesktopFile)
--- kdecore/services/kservice.cpp
+++ kdecore/services/kservice.cpp
@@ -300,7 +300,7 @@
                                << "has no Name or no Exec key";
             } else {
                 m_actions.append(KServiceAction(group,
-                                                cg.readEntry("Name"),
+                                                config->translatedEntry(cg,"Name"),
                                                 cg.readEntry("Icon"),
                                                 cg.readEntry("Exec"),
                                                 cg.readEntry("NoDisplay", false)));
--- kdecore/services/kservicegroup.cpp
+++ kdecore/services/kservicegroup.cpp
@@ -56,9 +56,9 @@
 
   const KConfigGroup config = desktopFile.desktopGroup();
 
-  m_strCaption = config.readEntry( "Name" );
-  m_strIcon = config.readEntry( "Icon" );
-  m_strComment = config.readEntry( "Comment" );
+  m_strCaption = desktopFile.readName();
+  m_strIcon = desktopFile.readIcon();
+  m_strComment = desktopFile.readComment();
   deleted = config.readEntry("Hidden", false );
   m_bNoDisplay = desktopFile.noDisplay();
   if (directoryEntryPath.startsWith(QDir::homePath()))
openSUSE Build Service is sponsored by