Fix i18n of header labels
authorLuciano Montanaro <mikelima@cirulla.net>
Tue, 10 Jan 2012 23:36:41 +0000 (00:36 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Tue, 10 Jan 2012 23:36:41 +0000 (00:36 +0100)
application/application.pro
application/resources/harmattan/qml/AboutPage.qml
application/resources/harmattan/qml/PageHeader.js [new file with mode: 0644]
application/resources/harmattan/qml/PageHeader.qml
application/resources/harmattan/qml/StationListPage.qml
application/resources/harmattan/qml/StationPage.qml

index 5472246..ce0393c 100644 (file)
@@ -112,6 +112,7 @@ QMLSOURCES = \
     resources/harmattan/qml/StationPage.qml \
     resources/harmattan/qml/SearchBar.qml \
     resources/harmattan/qml/PageHeader.qml \
+    resources/harmattan/qml/PageHeader.js \
     resources/harmattan/qml/uiconstants.js \
     resources/harmattan/qml/StationListPage.js \
     resources/harmattan/qml/AboutPage.qml \
index 75a341b..52b35d5 100644 (file)
@@ -13,12 +13,9 @@ Page {
         id: header
         anchors.top: parent.top
         selectedIndex: settings.showArrivalsPreferred ? 1 : 0
-        options: ListModel {
-            id: dialogOptions
-            ListElement {
-                name: QT_TR_NOOP("About Quando Parte")
-            }
-        }
+        options: [
+            qsTr("About Quando Parte")
+        ]
     }
     Label {
         anchors {
@@ -28,10 +25,12 @@ Page {
             margins: UiConstants.DefaultMargin
         }
         text: qsTr("<h2><a href='http://quandoparte.garage.maemo.org'>" +
-                   "Quando Parte" + "</a></h2>" +"<p style='font-size:small;'>version " + settings.versionString +
-                   "</p>" +
+                   "Quando Parte" + "</a></h2>" +"<p style='font-size:small;'>version ") +
+              settings.versionString +
+              qsTr("</p>" +
                    "<p>Copyright (c) 2010, 2011</p>" +
-                   "<p>Luciano Montanaro (<a href='mailto:mikelima@cirulla.net'>mikelima@cirulla.net</a>)</p>" +
+                   "<p>Luciano Montanaro " +
+                   "(<a href='mailto:mikelima@cirulla.net'>mikelima@cirulla.net</a>)</p>" +
                    "<p>Licensed under the GNU Public License v2 or above</p>" +
                    "<p/><p>Station geolocation data from " +
                    "<a href='http://www.openstreetmap.org'>OpenStreetMap</a></p>" +
diff --git a/application/resources/harmattan/qml/PageHeader.js b/application/resources/harmattan/qml/PageHeader.js
new file mode 100644 (file)
index 0000000..81183b9
--- /dev/null
@@ -0,0 +1,20 @@
+function setDisplayIndex(index) {
+    console.log("Selection changed to: " + index)
+    if (optionList === undefined || optionList.count === 0 ||
+            optionList.get(index) === undefined) {
+        header.text = " "
+    } else {
+        header.text = optionList.get(index).name
+        console.log("Selection text is: " + header.text)
+    }
+}
+
+function init()
+{
+    console.log("option length " + header.options.length)
+    for (var i = 0; i < header.options.length; ++i) {
+        console.log("option " + header.options[i])
+        optionList.append({name: header.options[i]})
+        Private.setDisplayIndex(selectedIndex)
+    }
+}
index e74ee12..5063562 100644 (file)
@@ -2,13 +2,16 @@ import QtQuick 1.0
 import com.nokia.meego 1.0
 import com.nokia.extras 1.0
 import "uiconstants.js" as UiConstants
+import "PageHeader.js" as Private
 
 Rectangle {
+    id: header
     property alias text: label.text
-    property alias options: dialog.model
     property alias selectedIndex: dialog.selectedIndex
+    property variant options: [
+        "Unnamed"
+    ]
 
-    id: root
     width: parent.width
     height: screen.currentOrientation === Screen.Landscape ?
                 UiConstants.HeaderDefaultHeightLandscape :
@@ -38,7 +41,7 @@ Rectangle {
     MouseArea {
         id: mouse
         anchors.fill: parent
-        onClicked: if (options.count > 1) dialog.open()
+        onClicked: if (optionList.count > 1) dialog.open()
     }
 
     Image {
@@ -49,25 +52,20 @@ Rectangle {
             horizontalCenter: (label.text != "") ? undefined : parent.horizontalCenter;
             verticalCenter: parent.verticalCenter;
         }
-        visible: options.count > 1
+        visible: optionList.count > 1
         height: label.height
         source: "image://theme/meegotouch-combobox-indicator" +
                 (style.inverted ? "-inverted" : "") +
-                (root.enabled ? "" : "-disabled") +
+                (header.enabled ? "" : "-disabled") +
                 (mouse.pressed ? "-pressed" : "")
     }
     SelectionDialog {
         id: dialog
         titleText: qsTr("Show")
-    }
-    onSelectedIndexChanged: {
-        console.log("Selection changed to: " + selectedIndex)
-        if (options === undefined || options.count === 0 ||
-                options.get(selectedIndex) === undefined) {
-            header.text = " "
-        } else {
-            header.text = options.get(selectedIndex).name
-            console.log("Selection text is: " + header.text)
+        model: ListModel {
+            id: optionList
         }
     }
+    onSelectedIndexChanged: Private.setDisplayIndex(selectedIndex)
+    Component.onCompleted: Private.init()
 }
index 7bcc5f9..1904340 100644 (file)
@@ -39,18 +39,11 @@ Page {
         id: header
         anchors.top: parent.top
         selectedIndex: stationListProxyModel.sortingMode
-        options: ListModel {
-            id: dialogOptions
-            ListElement {
-                name: QT_TR_NOOP("Stations by Name")
-            }
-            ListElement {
-                name: QT_TR_NOOP("Stations by Distance")
-            }
-            ListElement {
-                name: QT_TR_NOOP("Stations Recently Seen")
-            }
-        }
+        options: [
+            qsTr("Stations by Name"),
+            qsTr("Stations by Distance"),
+            qsTr("Stations Recently Seen")
+        ]
     }
     SearchBar {
         id: searchField
index 88bb6a3..7321dab 100644 (file)
@@ -16,15 +16,10 @@ Page {
         id: header
         anchors.top: parent.top
         selectedIndex: schedule.type
-        options: ListModel {
-            id: dialogOptions
-            ListElement {
-                name: QT_TR_NOOP("Departures")
-            }
-            ListElement {
-                name: QT_TR_NOOP("Arrivals")
-            }
-        }
+        options: [
+            qsTr("Departures"),
+            qsTr("Arrivals")
+        ]
     }
     InfoBar {
         id: infoBar