Commit bf6fb313 authored by Volker Krause's avatar Volker Krause

Fix i18n usage

i18n() is a lot more strict than qsTr() regarding what argument values it
accepts, so we need to be more careful with missing values there.
parent b9096f1a
add_definitions(-DTRANSLATION_DOMAIN=\"kde-itinerary\")
add_subdirectory(weather)
add_subdirectory(app)
......@@ -41,9 +41,7 @@ App.TimelineDelegate {
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("🚌 %1 %2")
.arg(reservation.reservationFor.busName)
.arg(reservation.reservationFor.busNumber)
text: i18n("🚌 %1", reservation.reservationFor.busName + " " + reservation.reservationFor.busNumber)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
......@@ -60,8 +58,7 @@ App.TimelineDelegate {
id: topLayout
QQC2.Label {
text: qsTr("From: %1")
.arg(reservation.reservationFor.departureStation.name)
text: i18n("From: %1", reservation.reservationFor.departureStation.name)
color: Kirigami.Theme.textColor
}
App.PlaceDelegate {
......@@ -72,8 +69,7 @@ App.TimelineDelegate {
Layout.fillWidth: true
}
QQC2.Label {
text: qsTr("To: %1")
.arg(reservation.reservationFor.arrivalStation.name)
text: i18n("To: %1", reservation.reservationFor.arrivalStation.name)
color: Kirigami.Theme.textColor
}
App.PlaceDelegate {
......@@ -81,7 +77,7 @@ App.TimelineDelegate {
Layout.fillWidth: true
}
QQC2.Label {
text: qsTr("Arrival: %1").arg(Localizer.formatDateTime(reservation.reservationFor, "arrivalTime"))
text: i18n("Arrival: %1", Localizer.formatDateTime(reservation.reservationFor, "arrivalTime"))
color: Kirigami.Theme.textColor
}
}
......
......@@ -25,7 +25,7 @@ import "." as App
App.DetailsPage {
id: root
title: qsTr("Bus Ticket")
title: i18n("Bus Ticket")
GridLayout {
id: grid
......@@ -50,11 +50,11 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Departure")
text: i18n("Departure")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Departure time:")
text: i18n("Departure time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "departureTime")
......@@ -78,11 +78,11 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Arrival")
text: i18n("Arrival")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Arrival time:")
text: i18n("Arrival time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "arrivalTime")
......@@ -106,11 +106,11 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Seat")
text: i18n("Seat")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Seat:")
text: i18n("Seat:")
}
QQC2.Label {
text: reservation.reservedTicket.ticketedSeat.seatNumber
......@@ -125,17 +125,17 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Booking")
text: i18n("Booking")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Booking reference:")
text: i18n("Booking reference:")
}
QQC2.Label {
text: reservation.reservationNumber
}
QQC2.Label {
text: qsTr("Under name:")
text: i18n("Under name:")
}
QQC2.Label {
text: reservation.underName.name
......
......@@ -43,7 +43,7 @@ Kirigami.AbstractCard {
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("⚠ Entering %1").arg(Localizer.countryName(countryInfo.isoCode))
text: i18n("⚠ Entering %1", Localizer.countryName(countryInfo.isoCode))
color: Kirigami.Theme.neutralTextColor
}
}
......@@ -54,24 +54,24 @@ Kirigami.AbstractCard {
QQC2.Label {
text: countryInfo.drivingSide == KItinerary.KnowledgeDb.DrivingSide.Right ?
qsTr("People are driving on the right side.") :
qsTr("People are driving on the wrong side.")
i18n("People are driving on the right side.") :
i18n("People are driving on the wrong side.")
color: Kirigami.Theme.negativeTextColor
visible: countryInfo.drivingSideDiffers
}
QQC2.Label {
text: qsTr("No compatible power sockets: %1").arg(countryInfo.powerSocketTypes)
text: i18n("No compatible power sockets: %1", countryInfo.powerSocketTypes)
color: Kirigami.Theme.negativeTextColor
visible: countryInfo.powerPlugCompatibility == CountryInformation.Incompatible
}
QQC2.Label {
text: qsTr("Some incompatible power sockets: %1").arg(countryInfo.powerSocketTypes)
text: i18n("Some incompatible power sockets: %1", countryInfo.powerSocketTypes)
color: Kirigami.Theme.neutralTextColor
visible: countryInfo.powerPlugCompatibility == CountryInformation.PartiallyCompatible && countryInfo.powerSocket != ""
visible: countryInfo.powerPlugCompatibility == CountryInformation.PartiallyCompatible && countryInfo.powerSocketTypes != ""
}
QQC2.Label {
text: qsTr("Some incompatible power plugs: %1").arg(countryInfo.powerPlugTypes)
text: i18n("Some incompatible power plugs: %1", countryInfo.powerPlugTypes)
color: Kirigami.Theme.neutralTextColor
visible: countryInfo.powerPlugCompatibility == CountryInformation.PartiallyCompatible && countryInfo.powerPlugTypes != ""
}
......
......@@ -33,14 +33,14 @@ Kirigami.ScrollablePage {
id: deleteWarningSheet
QQC2.Label {
text: qsTr("Do you really want to delete this event?")
text: i18n("Do you really want to delete this event?")
wrapMode: Text.WordWrap
}
footer: RowLayout {
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Delete")
text: i18n("Delete")
icon.name: "edit-delete"
onClicked: {
_reservationManager.removeReservation(root.resId)
......@@ -54,12 +54,12 @@ Kirigami.ScrollablePage {
contextualActions: [
Kirigami.Action {
iconName: "edit-delete"
text: qsTr("Delete")
text: i18n("Delete")
onTriggered: deleteWarningSheet.sheetOpen = true
},
Kirigami.Action {
iconSource: root.passId !== "" ? "image://org.kde.pkpass/" + passId + "/icon" : ""
text: qsTr("Boarding Pass")
text: i18n("Boarding Pass")
visible: root.passId !== ""
onTriggered: applicationWindow().pageStack.push(pkpassComponent, {"passId": root.passId });
}
......
......@@ -25,6 +25,14 @@ import "." as App
App.TimelineDelegate {
id: root
function airportDisplayString(airport)
{
if (airport.name) {
return airport.name;
}
return airport.iataCode;
}
header: Rectangle {
id: headerBackground
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
......@@ -41,11 +49,10 @@ App.TimelineDelegate {
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("✈ %1 %2 %3 → %4")
.arg(reservation.reservationFor.airline.iataCode)
.arg(reservation.reservationFor.flightNumber)
.arg(reservation.reservationFor.departureAirport.iataCode)
.arg(reservation.reservationFor.arrivalAirport.iataCode)
text: i18n("✈ %1 %2 → %3",
reservation.reservationFor.airline.iataCode + " " + reservation.reservationFor.flightNumber,
reservation.reservationFor.departureAirport.iataCode,
reservation.reservationFor.arrivalAirport.iataCode)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
......@@ -64,9 +71,9 @@ App.TimelineDelegate {
id: topLayout
QQC2.Label {
text: qsTr("Departure from %1: %2")
.arg(reservation.reservationFor.departureAirport.name)
.arg(Localizer.formatTime(reservation.reservationFor, "departureTime"))
text: i18n("Departure from %1: %2",
airportDisplayString(reservation.reservationFor.departureAirport),
Localizer.formatTime(reservation.reservationFor, "departureTime") + " ")
color: Kirigami.Theme.textColor
wrapMode: Text.WordWrap
Layout.maximumWidth: root.width
......@@ -76,10 +83,10 @@ App.TimelineDelegate {
Layout.fillWidth: true
}
QQC2.Label {
text: qsTr("Terminal: %1 Gate: %2 Seat: %3")
.arg(reservation.reservationFor.departureTerminal)
.arg(reservation.reservationFor.departureGate)
.arg(reservation.airplaneSeat)
text: i18n("Terminal: %1 Gate: %2 Seat: %3",
reservation.reservationFor.departureTerminal ? reservation.reservationFor.departureTerminal : "-",
reservation.reservationFor.departureGate ? reservation.reservationFor.departureGate : "-",
reservation.airplaneSeat ? reservation.airplaneSeat : "-")
color: Kirigami.Theme.textColor
}
......@@ -88,9 +95,9 @@ App.TimelineDelegate {
}
QQC2.Label {
text: qsTr("Arrival at %1: %2")
.arg(reservation.reservationFor.arrivalAirport.name)
.arg(Localizer.formatDateTime(reservation.reservationFor, "arrivalTime"))
text: i18n("Arrival at %1: %2",
airportDisplayString(reservation.reservationFor.arrivalAirport),
Localizer.formatDateTime(reservation.reservationFor, "arrivalTime") + " ")
color: Kirigami.Theme.textColor
wrapMode: Text.WordWrap
Layout.maximumWidth: root.width
......@@ -102,7 +109,7 @@ App.TimelineDelegate {
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Boarding Pass")
text: i18n("Boarding Pass")
onClicked: applicationWindow().pageStack.push(pkpassComponent, {"passId": root.passId });
visible: root.passId !== ""
icon.source: root.passId !== "" ? "image://org.kde.pkpass/" + passId + "/icon" : ""
......
......@@ -25,7 +25,7 @@ import "." as App
App.DetailsPage {
id: root
title: qsTr("Flight")
title: i18n("Flight")
GridLayout {
id: grid
......@@ -48,25 +48,25 @@ App.DetailsPage {
// flight details
QQC2.Label {
text: qsTr("Boarding time:")
text: i18n("Boarding time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "boardingTime")
}
QQC2.Label {
text: qsTr("Boarding group:")
text: i18n("Boarding group:")
}
QQC2.Label {
text: reservation.boardingGroup
}
QQC2.Label {
text: qsTr("Seat:")
text: i18n("Seat:")
}
QQC2.Label {
text: reservation.airplaneSeat
}
QQC2.Label {
text: qsTr("Airline:")
text: i18n("Airline:")
}
QQC2.Label {
text: reservation.reservationFor.airline.name
......@@ -81,11 +81,11 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Departure")
text: i18n("Departure")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Departure time:")
text: i18n("Departure time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "departureTime")
......@@ -100,13 +100,13 @@ App.DetailsPage {
place: reservation.reservationFor.departureAirport
}
QQC2.Label {
text: qsTr("Departure terminal:")
text: i18n("Departure terminal:")
}
QQC2.Label {
text: reservation.reservationFor.departureTerminal
}
QQC2.Label {
text: qsTr("Departure gate:")
text: i18n("Departure gate:")
}
QQC2.Label {
text: reservation.reservationFor.departureGate
......@@ -121,11 +121,11 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Arrival")
text: i18n("Arrival")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Arrival time:")
text: i18n("Arrival time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation.reservationFor, "arrivalTime")
......@@ -149,17 +149,17 @@ App.DetailsPage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Booking")
text: i18n("Booking")
horizontalAlignment: Qt.AlignHCenter
}
QQC2.Label {
text: qsTr("Booking reference:")
text: i18n("Booking reference:")
}
QQC2.Label {
text: reservation.reservationNumber
}
QQC2.Label {
text: qsTr("Under name:")
text: i18n("Under name:")
}
QQC2.Label {
text: reservation.underName.name
......
......@@ -42,8 +42,8 @@ App.TimelineDelegate {
QQC2.Label {
text: root.rangeType == TimelineModel.RangeEnd ?
qsTr("🏨 Check-out %1").arg(reservation.reservationFor.name) :
qsTr("🏨 %1").arg(reservation.reservationFor.name)
i18n("🏨 Check-out %1", reservation.reservationFor.name) :
i18n("🏨 %1", reservation.reservationFor.name)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
......@@ -59,15 +59,14 @@ App.TimelineDelegate {
Layout.fillWidth: true
}
QQC2.Label {
text: qsTr("Check-in time: %1")
.arg(Localizer.formatTime(reservation, "checkinTime"))
text: i18n("Check-in time: %1", Localizer.formatTime(reservation, "checkinTime"))
color: Kirigami.Theme.textColor
visible: root.rangeType == TimelineModel.RangeBegin
}
QQC2.Label {
text: root.rangeType == TimelineModel.RangeBegin ?
qsTr("Check-out time: %1").arg(Localizer.formatDateTime(reservation, "checkoutTime")) :
qsTr("Check-out time: %1").arg(Localizer.formatTime(reservation, "checkoutTime"))
i18n("Check-out time: %1", Localizer.formatDateTime(reservation, "checkoutTime")) :
i18n("Check-out time: %1", Localizer.formatTime(reservation, "checkoutTime"))
color: Kirigami.Theme.textColor
}
......
......@@ -25,7 +25,7 @@ import "." as App
App.DetailsPage {
id: root
title: qsTr("Hotel Reservation")
title: i18n("Hotel Reservation")
GridLayout {
id: grid
......@@ -48,39 +48,39 @@ App.DetailsPage {
// TODO make these interactive
QQC2.Label {
text: qsTr("Telephone:")
text: i18n("Telephone:")
}
QQC2.Label {
text: reservation.reservationFor.telephone
}
QQC2.Label {
text: qsTr("Email:")
text: i18n("Email:")
}
QQC2.Label {
text: reservation.reservationFor.email
}
QQC2.Label {
text: qsTr("Check-in time:")
text: i18n("Check-in time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation, "checkinTime")
}
QQC2.Label {
text: qsTr("Check-out time:")
text: i18n("Check-out time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation, "checkoutTime")
}
QQC2.Label {
text: qsTr("Booking reference:")
text: i18n("Booking reference:")
}
QQC2.Label {
text: reservation.reservationNumber
}
QQC2.Label {
text: qsTr("Under name:")
text: i18n("Under name:")
}
QQC2.Label {
text: reservation.underName.name
......
#! /usr/bin/env bash
$XGETTEXT `find . -name "*.cpp" -o -name "*.qml" -name "*.h"` -L Java -o $podir/itinerary.pot
......@@ -22,7 +22,7 @@ import "." as App
Kirigami.Page {
property alias passId: pkpass.passId
property alias pass: pkpass.pass
title: qsTr("Boarding Pass")
title: i18n("Boarding Pass")
App.BoardingPass {
x: (parent.width - implicitWidth) / 2
id: pkpass
......
......@@ -41,7 +41,7 @@ App.TimelineDelegate {
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("🍴 %1").arg(reservation.reservationFor.name)
text: i18n("🍴 %1", reservation.reservationFor.name)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
......
......@@ -25,7 +25,7 @@ import "." as App
App.DetailsPage {
id: root
title: qsTr("Restaurant Reservation")
title: i18n("Restaurant Reservation")
GridLayout {
id: grid
......@@ -48,45 +48,45 @@ App.DetailsPage {
// TODO make these interactive
QQC2.Label {
text: qsTr("Telephone:")
text: i18n("Telephone:")
}
QQC2.Label {
text: reservation.reservationFor.telephone
}
QQC2.Label {
text: qsTr("Email:")
text: i18n("Email:")
}
QQC2.Label {
text: reservation.reservationFor.email
}
QQC2.Label {
text: qsTr("Start time:")
text: i18n("Start time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation, "startTime")
}
QQC2.Label {
text: qsTr("End time:")
text: i18n("End time:")
}
QQC2.Label {
text: Localizer.formatDateTime(reservation, "endTime")
}
QQC2.Label {
text: qsTr("Party size:")
text: i18n("Party size:")
}
QQC2.Label {
text: reservation.partySize
}
QQC2.Label {
text: qsTr("Booking reference:")
text: i18n("Booking reference:")
}
QQC2.Label {
text: reservation.reservationNumber
}
QQC2.Label {
text: qsTr("Under name:")
text: i18n("Under name:")
}
QQC2.Label {
text: reservation.underName.name
......
......@@ -24,7 +24,7 @@ import "." as App
Kirigami.ScrollablePage {
id: root
title: qsTr("Settings")
title: i18n("Settings")
CountryModel {
id: countryModel
......@@ -35,7 +35,7 @@ Kirigami.ScrollablePage {
width: root.width
QQC2.Label {
text: qsTr("Home Country")
text: i18n("Home Country")
}
QQC2.ComboBox {
model: countryModel
......@@ -45,7 +45,7 @@ Kirigami.ScrollablePage {
}
QQC2.Label {
text: qsTr("Weather Forecast")
text: i18n("Weather Forecast")
}
QQC2.Switch {
id: weatherSwitch
......@@ -55,14 +55,14 @@ Kirigami.ScrollablePage {
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Showing weather forecasts will query online services.")
text: i18n("Showing weather forecasts will query online services.")
visible: !weatherSwitch.checked
}
// ATTENTION do not remove this note, see https://api.met.no/license_data.html
QQC2.Label {
Layout.columnSpan: 2
Layout.fillWidth: true
text: qsTr("Using data from <a href=\"https://www.met.no/\">The Norwegian Meteorological Institute</a> under <a href=\"https://creativecommons.org/licenses/by/4.0\">Creative Commons 4.0 BY International</a> license.")
text: i18n("Using data from <a href=\"https://www.met.no/\">The Norwegian Meteorological Institute</a> under <a href=\"https://creativecommons.org/licenses/by/4.0\">Creative Commons 4.0 BY International</a> license.")
visible: weatherSwitch.checked
wrapMode: Text.WordWrap
onLinkActivated: Qt.openUrlExternally(link)
......
......@@ -25,12 +25,12 @@ import "." as App
Kirigami.ScrollablePage {
id: root
title: qsTr("My Itinerary")
title: i18n("My Itinerary")
// context drawer content
actions {
contextualActions: [
Kirigami.Action {
text: qsTr("Today")
text: i18n("Today")
iconName: "view-calendar-day"
onTriggered: listView.positionViewAtIndex(_timelineModel.todayRow, ListView.Beginning);
}
......@@ -100,7 +100,7 @@ Kirigami.ScrollablePage {
QQC2.Label {
id: label
anchors.fill: parent
text: qsTr("Nothing on the itinerary for today.");
text: i18n("Nothing on the itinerary for today.");
color: Kirigami.Theme.textColor
horizontalAlignment: Qt.AlignHCenter
}
......
......@@ -41,7 +41,7 @@ App.TimelineDelegate {
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("🎢 %1").arg(reservation.touristAttraction.name)
text: i18n("🎢 %1", reservation.touristAttraction.name)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
......
......@@ -41,9 +41,7 @@ App.TimelineDelegate {
anchors.margins: Kirigami.Units.largeSpacing
QQC2.Label {
text: qsTr("🚄 %1 %2")
.arg(reservation.reservationFor.trainName)
.arg(reservation.reservationFor.trainNumber)
text: i18n("🚄 %1", reservation.reservationFor.trainName + " " + reservation.reservationFor.trainNumber)
color: Kirigami.Theme.textColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
Layout.fillWidth: true
......@@ -60,9 +58,9 @@ App.TimelineDelegate {
id: topLayout
QQC2.Label {
text: qsTr("Departure from %1 on platform %2")
.arg(reservation.reservationFor.departureStation.name)
.arg