Added localization
authorLuciano Montanaro <mikelima@cirula.net>
Mon, 16 May 2011 23:13:35 +0000 (01:13 +0200)
committerLuciano Montanaro <mikelima@zaphod>
Mon, 16 May 2011 23:13:35 +0000 (01:13 +0200)
Localization, with initial translation to Italian

application/application.pro
application/main.cpp
application/stationlistview.ui
application/stationview.cpp

index c195d69..68dcd95 100644 (file)
@@ -9,6 +9,8 @@ QT += webkit network xml maemo5
 TARGET = quandoparte
 TEMPLATE = app
 
+TRANSLATIONS = resources/i18n/quandoparte_it.ts
+
 SOURCES += main.cpp \
     settingsdialog.cpp \
     stationview.cpp \
@@ -26,7 +28,7 @@ FORMS += \
     stationlistview.ui
 
 CONFIG += webkit mobility
-MOBILITY = location bearer
+MOBILITY = location
 
 symbian {
     TARGET.UID3 = 0xe30fb688
@@ -46,8 +48,10 @@ OTHER_FILES += \
     icons/quandoparte.png \
     resources/quandoparte.css \
     resources/arrivals.css \
-    resources/departures.css
+    resources/departures.css \
+    $$replace(TRANSLATIONS, .ts, .qm)
 
+message($${OTHER_FILES})
 unix:!symbian {
     maemo5 {
         target.path = /opt/usr/bin
@@ -64,12 +68,19 @@ unix:!symbian {
     } else {
         desktopfile.path = /usr/share/applications
     }
-    INSTALLS += desktopfile cssfile
+    INSTALLS += desktopfile
 }
 
 unix:!symbian {
     css.files = resources/$${TARGET}.css resources/arrivals.css resources/departures.css
-    css.path = /usr/share/apps/$${TARGET}/css
+    i18n.files = $$replace(TRANSLATIONS, .ts, .qm)
+    maemo5 {
+       i18n.path = /opt/usr/share/apps/$${TARGET}/i18n
+       css.path = /opt/usr/share/apps/$${TARGET}/css
+    } else {
+       i18n.path = /usr/share/apps/$${TARGET}/i18n
+       css.path = /usr/share/apps/$${TARGET}/css
+    }
     icon48.files = icons/48x48/$${TARGET}.png
     icon64.files = icons/64x64/$${TARGET}.png
     icon48.path = /usr/share/icons/hicolor/48x48/apps
@@ -77,4 +88,5 @@ unix:!symbian {
     INSTALLS += icon48
     INSTALLS += icon64
     INSTALLS += css
+    INSTALLS += i18n
 }
index 91f0aef..a785ab7 100644 (file)
@@ -22,6 +22,9 @@ Boston, MA 02110-1301, USA.
 #include "app.h"
 
 #include <QApplication>
+#include <QDebug>
+#include <QLocale>
+#include <QTranslator>
 
 int main(int argc, char *argv[])
 {
@@ -29,6 +32,15 @@ int main(int argc, char *argv[])
     a.setApplicationName("QuandoParte");
     a.setOrganizationDomain("cirulla.net");
 
+    QString locale = QLocale::system().name();
+    QTranslator translator;
+    if (translator.load(QString("quandoparte_") + locale,
+                        "/opt/usr/share/apps/quandoparte/i18n")) {
+        qDebug() << "Translation for locale" << locale << "loaded";
+        a.installTranslator(&translator);
+    } else {
+        qDebug() << "Translation for locale" << locale << "not found";
+    }
     App theApp;
 
     return a.exec();
index 79ed0a4..9bc36b4 100644 (file)
@@ -6,12 +6,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>786</width>
-    <height>466</height>
+    <width>784</width>
+    <height>464</height>
    </rect>
   </property>
   <property name="windowTitle">
-   <string/>
+   <string>Station List</string>
   </property>
   <widget class="QWidget" name="centralWidget">
    <layout class="QVBoxLayout" name="verticalLayout">
@@ -25,7 +25,7 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>786</width>
+     <width>784</width>
      <height>25</height>
     </rect>
    </property>
index 47025e0..d085512 100644 (file)
@@ -153,10 +153,12 @@ void StationView::updateCss(void)
     qDebug() << styleSheet;
     //QUrl cssUrl = QUrl::fromEncoded(styleSheet);
     QUrl cssUrl;
+
+    // XXX Maemo5 specific
     if (showArrivalsAction->isChecked()) {
-        cssUrl.setEncodedUrl("file:///usr/share/apps/quandoparte/css/arrivals.css");
+        cssUrl.setEncodedUrl("file:///opt/usr/share/apps/quandoparte/css/arrivals.css");
     } else {
-        cssUrl.setEncodedUrl("file:///usr/share/apps/quandoparte/css/departures.css");
+        cssUrl.setEncodedUrl("file:///opt/usr/share/apps/quandoparte/css/departures.css");
     }
     QWebSettings::globalSettings()->setUserStyleSheetUrl(cssUrl);
 }