I have made the following changes intended for :
  nemo:devel:mw / mlite

Please review and accept or decline.
BOSS has already run some checks on this request.
See the "Messages from BOSS" section below.

https://build.merproject.org//request/show/99

Thank You,
Vesa Halttunen

[This message was auto-generated]

---

Request # 99:

Messages from BOSS:

State: review at 2013-03-26T13:49:13 by cibot

Reviews:
       new for home:vesuri:branches:nemo:devel:mw : 
       accepted by cibot : Prechecks succeeded.
       new for nemo:devel:mw : Please replace this text with a review and 
approve/reject the review (not the SR). BOSS will take care of the rest

Changes:
  submit: home:vesuri:branches:nemo:devel:mw / mlite -> nemo:devel:mw / mlite
  
changes files:
--------------
--- mlite.changes
+++ mlite.changes
@@ -0,0 +1,3 @@
+* Tue Mar 26 2013 Vesa Halttunen <[email protected]> - 0.0.11
+- Bring back the support for Harmattan style translation in translation 
catalogs
+

old:
----
  mlite-0.0.10.tar.bz2

new:
----
  mlite-0.0.11.tar.bz2

spec files:
-----------
--- mlite.spec
+++ mlite.spec
@@ -9,7 +9,7 @@
 # << macros
 
 Summary:    Useful classes originating from MeeGo Touch
-Version:    0.0.10
+Version:    0.0.11
 Release:    1
 Group:      System/Libraries
 License:    LGPL v2.1

other changes:
--------------

++++++ mlite-0.0.10.tar.bz2 -> mlite-0.0.11.tar.bz2
--- .gitignore
+++ .gitignore
@@ -0,0 +1,8 @@
+*~
+*.o
+*.so*
+Makefile
+*.pro.user
+.moc
+.obj
+mnotificationmanagerproxy.*
--- mdesktopentry.cpp
+++ mdesktopentry.cpp
@@ -2,11 +2,9 @@
 ** This file was derived from the MDesktopEntry implementation in the
 ** libmeegotouch library.
 **
-** Original Copyright:
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Copyright on new work:
-** Copyright 2011 Intel Corp.
+** Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Intel Corp.
+** Copyright (C) 2012, 2013 Jolla Ltd.
 **
 ** This library is free software; you can redistribute it and/or
 ** modify it under the terms of the GNU Lesser General Public
@@ -19,7 +17,8 @@
 #include <QRegExp>
 #include <QFile>
 #include <QStringList>
-#include <QLocale>
+#include <QCoreApplication>
+#include <QTranslator>
 #include <QTextStream>
 #include <QTextCodec>
 #include <QDebug>
@@ -49,6 +48,7 @@
 const QString LogicalIdKey("Desktop Entry/X-MeeGo-Logical-Id");
 const QString TranslationCatalogKey("Desktop 
Entry/X-MeeGo-Translation-Catalog");
 const QString XMaemoServiceKey("Desktop Entry/X-Maemo-Service");
+QMap<QString, QSharedPointer<QTranslator> > MDesktopEntryPrivate::translators;
 
 // The syntax of the locale string in the POSIX environment variables
 // related to locale is:
@@ -75,25 +75,13 @@
 
     if (regexp.indexIn(localeString) == 0 &&
             regexp.capturedTexts().size() == 6) { // size of regexp pattern 
above
-
-        *language = regexp.capturedTexts().at(1); // language
-
-        // POSIX locale modifier, interpreted as script
-        if (!regexp.capturedTexts().at(5).isEmpty())
-            *script = regexp.capturedTexts().at(5);
-        else
-            *script = "";
-
-        if (!regexp.capturedTexts().at(3).isEmpty())
-            *country = regexp.capturedTexts().at(3); // country
-        else
-            *country = "";
-    }
-    else
-    {
-        *language = "";
-        *script = "";
-        *country = "";
+        *language = regexp.capturedTexts().at(1);
+        *script = regexp.capturedTexts().at(5);
+        *country = regexp.capturedTexts().at(3);
+    } else {
+        *language = QString();
+        *script = QString();
+        *country = QString();
     }
 }
 
@@ -105,12 +93,27 @@
     QFile file(fileName);
 
     //Checks if the file exists and opens it in readonly mode
-    if (file.exists() && file.open(QIODevice::ReadOnly)) 
-    {
-        readDesktopFile(file, desktopEntriesMap);
-    } 
-    else 
-    {
+    if (file.exists() && file.open(QIODevice::ReadOnly)) {
+        if (readDesktopFile(file, desktopEntriesMap)) {
+            // Load the translation catalog if it has been defined for the 
entry.
+            if (desktopEntriesMap.contains(TranslationCatalogKey)) {
+                // Load the catalog from disk if it's not yet loaded
+                QString catalog = 
desktopEntriesMap.value(TranslationCatalogKey);
+                QString engineeringEnglishCatalog = catalog + "_eng_en";
+                if (!translators.contains(engineeringEnglishCatalog)) {
+                    translators[engineeringEnglishCatalog] = 
QSharedPointer<QTranslator>(new QTranslator(0));
+                    
translators[engineeringEnglishCatalog]->load(engineeringEnglishCatalog, 
"/usr/share/translations");
+                    
qApp->installTranslator(translators[engineeringEnglishCatalog].data());
+                }
+
+                if (!translators.contains(catalog)) {
+                    translators[catalog] = QSharedPointer<QTranslator>(new 
QTranslator(0));
+                    translators[catalog]->load(QLocale(), catalog, "-", 
"/usr/share/translations");
+                    qApp->installTranslator(translators[catalog].data());
+                }
+            }
+        }
+    } else {
         qDebug() << "Specified Desktop file does not exist" << fileName;
     }
 }
@@ -121,6 +124,13 @@
 
 bool MDesktopEntryPrivate::readDesktopFile(QIODevice &device, QMap<QString, 
QString> &desktopEntriesMap)
 {
+    valid = MDesktopEntry::readDesktopFile(device, desktopEntriesMap);
+    return valid;
+}
+
+bool MDesktopEntry::readDesktopFile(QIODevice &device, QMap<QString, QString> 
&desktopEntriesMap)
+{
+    bool valid = true;
     // Group header is of form [groupname]
     // The group name is captured
     // Group names may contain all ASCII characters except for [ and ] and 
control characters
@@ -307,15 +317,24 @@
 QString MDesktopEntry::name() const
 {
     QString name = value(NameKey);
-    QString lang, script, country, postfixKey;
-
-    parsePosixLang(getenv("LANG"), &lang, &country, &script);
 
-    if (contains(postfixKey = NameKey + '[' + lang + '_' + country  + '@' + 
script + ']') ||
-        contains(postfixKey = NameKey + '[' + lang + '_' + country  + ']') ||
-        contains(postfixKey = NameKey + '[' + lang + ']')) {
-        // Use the freedesktop.org standard localization style
-        name = value(postfixKey);
+    if (contains(LogicalIdKey)) {
+        name = qtTrId(value(LogicalIdKey).toAscii().data());
+    } else {
+        QString lang, variant, country, postfixKey;
+
+        parsePosixLang(getenv("LANG"), &lang, &country, &variant);
+        if (contains(postfixKey = NameKey + '[' + lang + '_' +
+                                  country  + '@' +
+                                  variant  + ']') ||
+                contains(postfixKey = NameKey + '[' + lang + '_' +
+                                      country  + ']') ||
+                contains(postfixKey = NameKey + '[' + lang + '@' +
+                                      variant  + ']') ||
+                contains(postfixKey = NameKey + '[' + lang + ']')) {
+            // Use the freedesktop.org standard localization style
+            name = value(postfixKey);
+        }
     }
 
     return name;
--- mdesktopentry.h
+++ mdesktopentry.h
@@ -2,11 +2,9 @@
 ** This file was derived from the MDesktopEntry implementation in the
 ** libmeegotouch library.
 **
-** Original Copyright:
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Copyright on new work:
-** Copyright 2011 Intel Corp.
+** Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Intel Corp.
+** Copyright (C) 2012, 2013 Jolla Ltd.
 **
 ** This library is free software; you can redistribute it and/or
 ** modify it under the terms of the GNU Lesser General Public
@@ -230,6 +228,15 @@
      */
     bool contains(const QString &group, const QString &key) const;
 
+    /*!
+     * Parses a desktop entry file.
+     *
+     * \param device the QIODevice to read the desktop file from
+     * \param map the QMap to store key-value pairs to
+     * \return true if desktop file can be parsed
+     */
+    static bool readDesktopFile(QIODevice &device, QMap<QString, QString> 
&desktopEntriesMap);
+
 protected:
     /*! \internal */
     //! Pointer to the private class
--- mdesktopentry_p.h
+++ mdesktopentry_p.h
@@ -1,13 +1,10 @@
 /***************************************************************************
+** This file was derived from the MDesktopEntry implementation in the
+** libmeegotouch library.
 **
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation ([email protected])
-**
-** This file is part of libmeegotouch.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at [email protected].
+** Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Intel Corp.
+** Copyright (C) 2012, 2013 Jolla Ltd.
 **
 ** This library is free software; you can redistribute it and/or
 ** modify it under the terms of the GNU Lesser General Public
@@ -20,7 +17,10 @@
 #ifndef MDESKTOPENTRY_P_H
 #define MDESKTOPENTRY_P_H
 
+#include <QSharedPointer>
+
 class MDesktopEntry;
+class QTranslator;
 
 /*!
  * MDesktopEntryPrivate is the private class for MDesktopEntry.
@@ -57,6 +57,9 @@
     //! A map for storing the desktop entries keys and their corresponding 
values
     QMap<QString, QString> desktopEntriesMap;
 
+    //! A map for storing translators for translation catalogs
+    static QMap<QString, QSharedPointer<QTranslator> > translators;
+
     /*!
      * Returns the boolean value of a key.
      *
--- mlite.pro
+++ mlite.pro
@@ -81,7 +81,7 @@
 INSTALLS += target headers pcfiles
 
 TRANSLATIONS += $${SOURCES} $${HEADERS} $${OTHER_FILES}
-VERSION = 0.0.10
+VERSION = 0.0.11
 PROJECT_NAME = mlite
 
 dist.commands += rm -fR $${PROJECT_NAME}-$${VERSION} &&
--- tools/mlitenotificationtool/.gitignore
+++ tools/mlitenotificationtool/.gitignore
@@ -0,0 +1 @@
+mlitenotificationtool

++++++ mlite.yaml
--- mlite.yaml
+++ mlite.yaml
@@ -1,6 +1,6 @@
 Name: mlite
 Summary: Useful classes originating from MeeGo Touch
-Version: 0.0.10
+Version: 0.0.11
 Release: 1
 Group: System/Libraries
 License: LGPL v2.1



Reply via email to