From 9e4e62eed651c2ce2162b3292e1b7cfc5d9965bb Mon Sep 17 00:00:00 2001 From: Kaustuv Pokharel Date: Mon, 27 Oct 2025 21:03:07 -0400 Subject: [PATCH 1/4] changed tr text from arg to %n for plural translations to work --- app/inpututils.cpp | 4 ++-- app/qml/map/MMSplittingTools.qml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/inpututils.cpp b/app/inpututils.cpp index 0850cb93b..e8bb40149 100644 --- a/app/inpututils.cpp +++ b/app/inpututils.cpp @@ -2099,11 +2099,11 @@ QString InputUtils::invalidGeometryWarning( QgsVectorLayer *layer ) if ( QgsWkbTypes::isMultiType( layer->wkbType() ) ) { - return tr( "You need to add at least %1 point(s) to every part." ).arg( nPoints ); + return tr( "You need to add at least %n point(s) to every part.", "", nPoints ); } else { - return tr( "You need to add at least %1 point(s)." ).arg( nPoints ); + return tr( "You need to add at least %n point(s).", "", nPoints ); } } diff --git a/app/qml/map/MMSplittingTools.qml b/app/qml/map/MMSplittingTools.qml index 74fa1400b..670298085 100644 --- a/app/qml/map/MMSplittingTools.qml +++ b/app/qml/map/MMSplittingTools.qml @@ -111,6 +111,7 @@ Item { else { __notificationModel.addWarning( qsTr( "You need to add at least 2 points." ) ) + //__notificationModel.addWarning( __inputUtils.invalidGeometryWarning( mapTool.activeLayer ) ) } } } From 81c00af33dfb97e48ebc7a0cbbbc796f27ee4f08 Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Mon, 24 Nov 2025 18:48:27 +0200 Subject: [PATCH 2/4] Removed comment --- app/qml/map/MMSplittingTools.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/qml/map/MMSplittingTools.qml b/app/qml/map/MMSplittingTools.qml index 670298085..74fa1400b 100644 --- a/app/qml/map/MMSplittingTools.qml +++ b/app/qml/map/MMSplittingTools.qml @@ -111,7 +111,6 @@ Item { else { __notificationModel.addWarning( qsTr( "You need to add at least 2 points." ) ) - //__notificationModel.addWarning( __inputUtils.invalidGeometryWarning( mapTool.activeLayer ) ) } } } From 629c67aba417e48998c852ac7190f4dce84a6efc Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Tue, 25 Nov 2025 09:22:03 +0200 Subject: [PATCH 3/4] Modified some if statements for translations --- app/inpututils.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/inpututils.cpp b/app/inpututils.cpp index e8bb40149..8541cddb2 100644 --- a/app/inpututils.cpp +++ b/app/inpututils.cpp @@ -238,36 +238,36 @@ QString InputUtils::formatDateTimeDiff( const QDateTime &tMin, const QDateTime & else if ( secsDiff < 60 * 60 ) { int period = secsDiff / 60 ; - return ( period > 1 ) ? tr( "%1 minutes ago" ).arg( period ) : tr( "%1 minute ago" ).arg( period ); + return tr( "%n minute(s) ago", "", period ); } else if ( secsDiff < 60 * 60 * 24 ) { int period = secsDiff / ( 60 * 60 ); - return ( period > 1 ) ? tr( "%1 hours ago" ).arg( period ) : tr( "%1 hour ago" ).arg( period ); + return tr( "%n hours(s) ago", "", period ); } else { - return ( daysDiff > 1 ) ? tr( "%1 days ago" ).arg( daysDiff ) : tr( "%1 day ago" ).arg( daysDiff ); + return tr( "%n day(s) ago", "", daysDiff ); } } else if ( daysDiff < 7 ) { - return ( daysDiff > 1 ) ? tr( "%1 days ago" ).arg( daysDiff ) : tr( "%1 day ago" ).arg( daysDiff ); + return tr( "%n days(s) ago", "", daysDiff ); } else if ( daysDiff < 31 ) { int period = daysDiff / 7; - return ( period > 1 ) ? tr( "%1 weeks ago" ).arg( period ) : tr( "%1 week ago" ).arg( period ); + return tr( "%n week(s) ago", "", period ); } else if ( daysDiff < 365 ) { int period = daysDiff / 31; - return ( period > 1 ) ? tr( "%1 months ago" ).arg( period ) : tr( "%1 month ago" ).arg( period ); + return tr( "%n month(s) ago", "", period ); } else { int period = daysDiff / 365; - return ( period > 1 ) ? tr( "%1 years ago" ).arg( period ) : tr( "%1 year ago" ).arg( period ); + return tr( "%n year(s) ago", "", period ); } return INVALID_DATETIME_STR; From e44cb8478aa22d88e15cc52d35128d27cde44837 Mon Sep 17 00:00:00 2001 From: Gabriel Bolbotina Date: Tue, 25 Nov 2025 12:55:41 +0200 Subject: [PATCH 4/4] Updated test Utils for the added time logic --- app/inpututils.cpp | 4 ++-- app/qml/main.qml | 2 +- app/test/testutilsfunctions.cpp | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/inpututils.cpp b/app/inpututils.cpp index 8541cddb2..d588395a5 100644 --- a/app/inpututils.cpp +++ b/app/inpututils.cpp @@ -243,7 +243,7 @@ QString InputUtils::formatDateTimeDiff( const QDateTime &tMin, const QDateTime & else if ( secsDiff < 60 * 60 * 24 ) { int period = secsDiff / ( 60 * 60 ); - return tr( "%n hours(s) ago", "", period ); + return tr( "%n hour(s) ago", "", period ); } else { @@ -252,7 +252,7 @@ QString InputUtils::formatDateTimeDiff( const QDateTime &tMin, const QDateTime & } else if ( daysDiff < 7 ) { - return tr( "%n days(s) ago", "", daysDiff ); + return tr( "%n day(s) ago", "", daysDiff ); } else if ( daysDiff < 31 ) { diff --git a/app/qml/main.qml b/app/qml/main.qml index a5b86999b..2c7addda8 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -671,7 +671,7 @@ ApplicationWindow { property int countToDelete: 0 - title: qsTr( "Delete feature(s)", "", countToDelete ) + title: qsTr( "Delete %n feature(s)", "", countToDelete ) description: qsTr( "Delete %n selected feature(s)?", "", countToDelete ) primaryButton.text: qsTr( "Yes, I want to delete" ) diff --git a/app/test/testutilsfunctions.cpp b/app/test/testutilsfunctions.cpp index ca5ffa41b..aaa72c94e 100644 --- a/app/test/testutilsfunctions.cpp +++ b/app/test/testutilsfunctions.cpp @@ -52,18 +52,18 @@ void TestUtilsFunctions::testFormatDuration() testFormatDuration( t0, -1, QStringLiteral( "Invalid datetime" ) ); testFormatDuration( t0, 0, QStringLiteral( "just now" ) ); testFormatDuration( t0, 1, QStringLiteral( "just now" ) ); - testFormatDuration( t0, 60, QStringLiteral( "1 minute ago" ) ); - testFormatDuration( t0, 2 * 60, QStringLiteral( "2 minutes ago" ) ); - testFormatDuration( t0, 1 * 60 * 60, QStringLiteral( "1 hour ago" ) ); - testFormatDuration( t0, 2 * 60 * 60, QStringLiteral( "2 hours ago" ) ); - testFormatDuration( t0, 1 * DAY_IN_SECS, QStringLiteral( "1 day ago" ) ); - testFormatDuration( t0, 2 * DAY_IN_SECS, QStringLiteral( "2 days ago" ) ); - testFormatDuration( t0, 7 * DAY_IN_SECS, QStringLiteral( "1 week ago" ) ); - testFormatDuration( t0, 14 * DAY_IN_SECS, QStringLiteral( "2 weeks ago" ) ); - testFormatDuration( t0, MONTH_IN_SECS, QStringLiteral( "1 month ago" ) ); - testFormatDuration( t0, 2 * MONTH_IN_SECS, QStringLiteral( "2 months ago" ) ); - testFormatDuration( t0, 12 * MONTH_IN_SECS, QStringLiteral( "1 year ago" ) ); - testFormatDuration( t0, 24 * MONTH_IN_SECS, QStringLiteral( "2 years ago" ) ); + testFormatDuration( t0, 60, QStringLiteral( "1 minute(s) ago" ) ); + testFormatDuration( t0, 2 * 60, QStringLiteral( "2 minute(s) ago" ) ); + testFormatDuration( t0, 1 * 60 * 60, QStringLiteral( "1 hour(s) ago" ) ); + testFormatDuration( t0, 2 * 60 * 60, QStringLiteral( "2 hour(s) ago" ) ); + testFormatDuration( t0, 1 * DAY_IN_SECS, QStringLiteral( "1 day(s) ago" ) ); + testFormatDuration( t0, 2 * DAY_IN_SECS, QStringLiteral( "2 day(s) ago" ) ); + testFormatDuration( t0, 7 * DAY_IN_SECS, QStringLiteral( "1 week(s) ago" ) ); + testFormatDuration( t0, 14 * DAY_IN_SECS, QStringLiteral( "2 week(s) ago" ) ); + testFormatDuration( t0, MONTH_IN_SECS, QStringLiteral( "1 month(s) ago" ) ); + testFormatDuration( t0, 2 * MONTH_IN_SECS, QStringLiteral( "2 month(s) ago" ) ); + testFormatDuration( t0, 12 * MONTH_IN_SECS, QStringLiteral( "1 year(s) ago" ) ); + testFormatDuration( t0, 24 * MONTH_IN_SECS, QStringLiteral( "2 year(s) ago" ) ); } void TestUtilsFunctions::testFormatDuration( const QDateTime &t0, qint64 diffSecs, const QString &expectedResult )