diff --git a/app/inpututils.cpp b/app/inpututils.cpp index 0850cb93b..d588395a5 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 hour(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 day(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; @@ -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/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 )