From 6594304deb675bcd5d60aa17bb6ffaa98cab2fb5 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sun, 20 Jun 2021 20:11:19 +0200 Subject: [PATCH] Started to make strings translatable --- resources/qml/Components/QrCodeScanPopup.qml | 12 ++-- .../qml/Components/SpeedFlowChartLocker.qml | 49 ++++++++------ resources/qml/Pages/StartPage.qml | 19 ++++-- resources/qml/Widgets/CalendarWidget.qml | 29 ++++++--- resources/qml/Widgets/ProfileWidget.qml | 15 +++-- resources/qml/Widgets/RankingWidget.qml | 3 +- resources/qml/Widgets/RegistrationWidget.qml | 5 +- resources/qml/Widgets/ResultWidget.qml | 6 +- resources/qml/Widgets/StartlistWidget.qml | 7 +- resources/qml/main.qml | 64 ++++--------------- 10 files changed, 106 insertions(+), 103 deletions(-) diff --git a/resources/qml/Components/QrCodeScanPopup.qml b/resources/qml/Components/QrCodeScanPopup.qml index a02f341..f394fea 100644 --- a/resources/qml/Components/QrCodeScanPopup.qml +++ b/resources/qml/Components/QrCodeScanPopup.qml @@ -23,7 +23,8 @@ Dialog { width: app.width * 0.8 modal: true - title: "Scan QR-Code" + //% "Scan QR-Code" + title: qsTrId("scanQrCode") standardButtons: Dialog.Cancel @@ -36,7 +37,8 @@ Dialog { onClosed: cameraLoader.sourceComponent = null function setDefaultStatusText() { - _statusText = "Place the Code in the center" + //% "Place the Code in the center" + _statusText = qsTrId("placeQrCodeInCenter") _statusColor = Material.primaryTextColor } @@ -177,12 +179,14 @@ Dialog { control._freezeScanning = true - control._statusText = "Plase wait..." + //% "Plase wait" + control._statusText = qsTrId("pleaseWait") + "..." if(app.openWidgetFromUrl(tag)) control.close() else { - control._statusText = "Invalid QR-Code" + //% "Invalid QR-Code" + control._statusText = qsTrId("invalidQrCode") control._statusColor = Material.color(Material.Red) statusTextResetTimer.start() control._freezeScanning = false diff --git a/resources/qml/Components/SpeedFlowChartLocker.qml b/resources/qml/Components/SpeedFlowChartLocker.qml index 954d88a..10f2b43 100644 --- a/resources/qml/Components/SpeedFlowChartLocker.qml +++ b/resources/qml/Components/SpeedFlowChartLocker.qml @@ -16,7 +16,8 @@ Rectangle { target: speedFlowChartProduct function onPurchaseFailed() { - purchaseBt.text = qsTr("Purchase failed") + //% "Purchase failed" + purchaseBt.text = qsTrId("purchaseFailed") purchaseBt.enabled = false buttonTextResetTimer.start() } @@ -29,8 +30,10 @@ Rectangle { repeat: false onTriggered: { purchaseBt.text = (speedFlowChartProduct.status === Product.Registered - ? "Buy now for " + speedFlowChartProduct.price - : qsTr("this item is currently unavailable")) + //% "Buy now for" + ? qsTrId("buyNowFor") + " " + speedFlowChartProduct.price + //% "This item is currently unavailable" + : qsTrId("itemUnavailable")) purchaseBt.enabled = true } } @@ -53,7 +56,8 @@ Rectangle { height: parent.height * 0.015 - text: qsTr("This is a premium feature.") + //% "This is a premium feature." + text: qsTrId("thisIsAPremiumFeature") font.bold: true font.pixelSize: height @@ -83,8 +87,9 @@ Rectangle { Layout.alignment: Layout.Center enabled: speedFlowChartProduct.status === Product.Registered text: speedFlowChartProduct.status === Product.Registered - ? "\uf218 Buy now for " + speedFlowChartProduct.price - : qsTr("This item is currently unavailable") + ? "\uf218 "+ qsTrId("buyNowFor") +" " + speedFlowChartProduct.price + //% "This item is currently unavailable" + : qsTrId("itemIsUnavailable") font.family: fa5solid.name onClicked: speedFlowChartProduct.purchase() } @@ -93,26 +98,28 @@ Rectangle { Layout.alignment: Layout.Center - Button { - id: restorePurchaseButton - Layout.alignment: Layout.Center - visible: speedFlowChartProduct.status === Product.Registered + Button { + id: restorePurchaseButton + Layout.alignment: Layout.Center + visible: speedFlowChartProduct.status === Product.Registered - flat: true - text: "restore purchase" + flat: true + //% "Restore purchase" + text: qsTrId("restorePurchase") - onClicked: inAppProductStore.restorePurchases() - } + onClicked: inAppProductStore.restorePurchases() + } - Button { - id: contactSupportButton - Layout.alignment: Layout.Center + Button { + id: contactSupportButton + Layout.alignment: Layout.Center - flat: true - text: "contact support" + flat: true + //% "contact support" + text: qsTrId("contact support") - onClicked: Qt.openUrlExternally("mailto:contact@itsblue.de") - } + onClicked: Qt.openUrlExternally("mailto:contact@itsblue.de") + } } } diff --git a/resources/qml/Pages/StartPage.qml b/resources/qml/Pages/StartPage.qml index 7734679..4181ca5 100644 --- a/resources/qml/Pages/StartPage.qml +++ b/resources/qml/Pages/StartPage.qml @@ -104,10 +104,21 @@ Page { Repeater { id: buttonRepeater property var buttons: [ - ["\uf059", "IFSC results", ifscDisclaimerDialog.open], - ["\uf042", Material.theme === Material.Light ? "Dark mode":"Light mode", app.toggleDarkMode], - ["\uf05a", "About blueROCK", aboutBluerockDisclaimerDialog.open], - ["\uf029", "Scan QR code", qrCodeScanPopup.open], + //% "IFSC results" + ["\uf059", qsTrId("ifscResults"), ifscDisclaimerDialog.open], + [ + "\uf042", + Material.theme === Material.Light ? + //% "Dark mode" + qsTrId("darkMode"): + //% "Light mode" + qsTrId("lightMode"), + app.toggleDarkMode + ], + //% "About blueROCK" + ["\uf05a", qsTrId("aboutBluerock"), aboutBluerockDisclaimerDialog.open], + //% "Scan QR code" + ["\uf029", qsTrId("scanQrCode"), qrCodeScanPopup.open], ] model: buttons diff --git a/resources/qml/Widgets/CalendarWidget.qml b/resources/qml/Widgets/CalendarWidget.qml index d2c248f..2a82889 100644 --- a/resources/qml/Widgets/CalendarWidget.qml +++ b/resources/qml/Widgets/CalendarWidget.qml @@ -28,7 +28,8 @@ DataListView { property bool ready - property string title: (params.nation === "ICC" ? "IFSC":params.nation === "GER" ? "DAV":"SAC") + " " + qsTr("calendar") + " " + control.year + //% "calendar" + property string title: (params.nation === "ICC" ? "IFSC":params.nation === "GER" ? "DAV":"SAC") + " " + qsTrId("calendar") + " " + control.year property Component headerComponent: RowLayout { @@ -63,13 +64,15 @@ DataListView { } } - compCats.push( {"text": qsTr("Favorites"), "data": {"sort_rank":0, "cat_id":[-1]}} ) + //% "Favorites" + compCats.push( {"text": qsTrId("favorites"), "data": {"sort_rank":0, "cat_id":[-1]}} ) compCats.sort(function(a, b) { return a['data']['sort_rank'] - b['data']['sort_rank']; }); - filterSelectPu.appear(compCats, qsTr("Select Filters"), "") + //% "Select filters" + filterSelectPu.appear(compCats, qsTrId("selectFilters"), "") } text: "\uf0b0" @@ -202,13 +205,18 @@ DataListView { var infoUrls = getCompInfoUrls(compIndex) var infosheet = ""; if(infoUrls.length >= 1) - infosheet += ("" + qsTr('infosheet') + "") + //% "Infosheet" + infosheet += ("" + qsTrId('infosheet') + "") if(infoUrls.length === 2) - infosheet += (", " + qsTr('further infos') + "") + //% "Further infos" + infosheet += (", " + qsTrId('furtherInfos') + "") console.log("Infosheet: " + infosheet) - var eventWebsite = control.widgetData["competitions"][compIndex]["homepage"] !== undefined ? ("" + qsTr('Event Website') + ""):"" + + var eventWebsite = control.widgetData["competitions"][compIndex]["homepage"] !== undefined ? + //% "Event website" + ("" + qsTrId('eventWebsite') + ""):"" selector.appear(selectOptions, control.widgetData["competitions"][compIndex]['name'], eventWebsite + ((eventWebsite !== "" && infosheet !== "") ? ", ":"") + infosheet ) } @@ -224,7 +232,8 @@ DataListView { } } - selector.appear(selectOptions, qsTr("select year")) + //% "Select year" + selector.appear(selectOptions, qsTrId("selectYear")) } function openCup(state, data) { @@ -236,7 +245,8 @@ DataListView { if(state === undefined){ // opened for the first time -> select cup - selectTitle = qsTr("select cup") + //% "Select cup" + selectTitle = qsTrId("selectCup") cups.sort(function(a, b) { return parseInt(b["SerId"]) - parseInt(a["SerId"]); @@ -264,7 +274,8 @@ DataListView { return } - selectTitle = cup['name'] + ": " + qsTr("select category") + //% "Select category" + selectTitle = cup['name'] + ": " + qsTrId("selectCategory") // build a list with all cat in the cup out of the cat keys (rkey) given in the cup.cats for(prop in cup['cats']){ diff --git a/resources/qml/Widgets/ProfileWidget.qml b/resources/qml/Widgets/ProfileWidget.qml index 55058b0..76869b1 100644 --- a/resources/qml/Widgets/ProfileWidget.qml +++ b/resources/qml/Widgets/ProfileWidget.qml @@ -190,7 +190,8 @@ Page { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter - text: qsTr("age") + ": " + widgetData["age"] + //% "Age" + text: qsTrId("age") + ": " + widgetData["age"] } Label { @@ -206,7 +207,8 @@ Page { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter - text: qsTr("year of birth") + ": " + widgetData["birthdate"] + //% "Year of birth" + text: qsTrId("yearOfBirth") + ": " + widgetData["birthdate"] } Label { @@ -222,7 +224,8 @@ Page { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter - text: qsTr("city") + ": " + widgetData["city"] + //% "City" + text: qsTrId("city") + ": " + widgetData["city"] } } @@ -263,7 +266,11 @@ Page { flat: true - text: bestResultsRep.showAllResults ? qsTr("show best results"):qsTr("show all results") + text: bestResultsRep.showAllResults ? + //% "Show best results" + qsTrId("showBestResults"): + //% "Show all results" + qsTrId("showAllResults") onClicked: { bestResultsRep.showAllResults = !bestResultsRep.showAllResults diff --git a/resources/qml/Widgets/RankingWidget.qml b/resources/qml/Widgets/RankingWidget.qml index 2392773..5bdbc1c 100644 --- a/resources/qml/Widgets/RankingWidget.qml +++ b/resources/qml/Widgets/RankingWidget.qml @@ -27,7 +27,8 @@ DataListView { property bool ready property string title: control.widgetData['comp_name'] - property string subTitle: qsTr("(Ranking)") + " after " + control.widgetData['route_name'] + //% "(Ranking)" + property string subTitle: qsTrId("rankingHeadline") + " after " + control.widgetData['route_name'] property bool titleIsPageTitle: true property var widgetData: currentWidgetData diff --git a/resources/qml/Widgets/RegistrationWidget.qml b/resources/qml/Widgets/RegistrationWidget.qml index 68642c5..8d29df2 100644 --- a/resources/qml/Widgets/RegistrationWidget.qml +++ b/resources/qml/Widgets/RegistrationWidget.qml @@ -57,7 +57,8 @@ DataListView { } } - var addition = "(Registration) " + //% "(Registration)" + var addition = qsTrId("registrationHeadline") if(titleString !== undefined){ return addition + " " + titleString @@ -108,7 +109,7 @@ DataListView { } } - selector.appear(selectOptions, qsTr("select cat")) + selector.appear(selectOptions, qsTrId("selectCategory")) } function filterAthletes(athletes) { diff --git a/resources/qml/Widgets/ResultWidget.qml b/resources/qml/Widgets/ResultWidget.qml index 418aa5d..33bc4ec 100644 --- a/resources/qml/Widgets/ResultWidget.qml +++ b/resources/qml/Widgets/ResultWidget.qml @@ -132,8 +132,8 @@ DataListView { titleString = control.widgetData["categorys"][i]["name"] } } - - var addition = qsTr("(Results)") + //% "(Results)" + var addition = qsTrId("resultsHeadline") if(titleString !== undefined){ return addition + " " + titleString @@ -166,7 +166,7 @@ DataListView { } } - selector.appear(selectOptions, qsTr("select cat")) + selector.appear(selectOptions, qsTrId("selectCategory")) } Connections { diff --git a/resources/qml/Widgets/StartlistWidget.qml b/resources/qml/Widgets/StartlistWidget.qml index df248eb..fe1e23f 100644 --- a/resources/qml/Widgets/StartlistWidget.qml +++ b/resources/qml/Widgets/StartlistWidget.qml @@ -28,7 +28,7 @@ DataListView { property bool ready property string title: control.widgetData['comp_name'] - property string subTitle: qsTr("(Startlist)") + " " + control.widgetData['route_name'] //getSubtitle() + property string subTitle: getSubtitle() property bool titleIsPageTitle: true property Component headerComponent: ToolButton { @@ -52,7 +52,8 @@ DataListView { } } - var addition = qsTr("(Startlist)") + //% "(Startlist)" + var addition = qsTrId("startlistHeadline") return addition + " " + titleString } @@ -78,7 +79,7 @@ DataListView { } } - selector.appear(selectOptions, qsTr("select cat")) + selector.appear(selectOptions, qsTrId("startlistHeadline")) } Connections { diff --git a/resources/qml/main.qml b/resources/qml/main.qml index 3c0466b..356c2d0 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -34,7 +34,7 @@ Window { visible: true width: 540 height: 960 - title: qsTr("blueROCK") + title: "blueROCK" Page { id: app @@ -656,76 +656,36 @@ Window { // 2 - error var errorString - var errorDescription switch(errorCode) { case 0: infoLevel = 2 - errorString = "No connection to server" - errorDescription = "Please check your internet connection and try again." - break - case 200: - infoLevel = 0 - errorString = "Success" - errorDescription = "The request was successfull" - break - case 401: - infoLevel = 2 - errorString = "Authentication required" - errorDescription = "The server asked for user credentinals, please chack them and try again" + //% "No connection to server" + errorString = qsTrId("noConnectionError") break case 404: infoLevel = 2 - errorString = "Not found" - errorDescription = "The requested item was not found" - break - case 500: - infoLevel = 2 - errorString = "Internal server error" - errorDescription = "The server was unable to process this request, this is probaply the servers fault. Please try again later." - break - case 900: - infoLevel = 2 - errorString = "Internal error" - errorDescription = "Something went wron internally, this is probaply an inssue in the program code" + //% "Not found" + errorString = qsTrId("notFoundError") break case 901: infoLevel = 1 - errorString = "No Data" - errorDescription = "There is currently no data available. Please try again later." - break - case 902: - infoLevel = 1 - errorString = "Cached (old) data" - errorDescription = "Es konnte keine Verbindung zum Server hergestellt werden, aber es sind noch alte Daten gespeichert." - break - case 903: - infoLevel = 1 - errorString = "Ungültiger Aufruf" - errorDescription = "Die aufgerufene Funktion ist momentan nicht verfügbar, bitte versuche es später erneut." - break - case 904: - infoLevel = 2 - errorString = "Incompatible API" - errorDescription = "Please make shure that you are using the latest version of this app and try again." - break - case 905: - infoLevel = 1 - errorString = "Loading..." - errorDescription = "Please wait while we're loading some data" + //% "No Data" + errorString = qsTrId("noDataError") break case 906: infoLevel = 2 - errorString = "Invalid Request" + //% "Invalid Request" + errorString = qsTrId("invalidRequestError") errorDescription = "Invalid Request" break default: infoLevel = 2 - errorString = "Unexpected error ("+errorCode+")" - errorDescription = "Unexpected error while getting data from the server. Please try again later." + //% "Unexpected error" + errorString = qsTrId("unexpectedError") + " ("+errorCode+")" } - return([infoLevel, errorString, errorDescription]) + return([infoLevel, errorString]) } }