From 162ee870b95c6176773c7ffc078a60d946150635 Mon Sep 17 00:00:00 2001 From: Christoph <47949835+shtrophic@users.noreply.github.com> Date: Sun, 23 Mar 2025 20:39:42 +0100 Subject: [PATCH] LocationItem: localize departure time preview (#1294) * localize departure time preview * use plurals * use plural format string correctly --- .../launcher2/ui/launcher/search/location/LocationItem.kt | 7 +++++-- core/i18n/src/main/res/values-de/strings.xml | 5 +++++ core/i18n/src/main/res/values/strings.xml | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/location/LocationItem.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/location/LocationItem.kt index f80508a5..4efa636d 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/location/LocationItem.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/search/location/LocationItem.kt @@ -453,8 +453,11 @@ fun LocationItem( java.time.LocalTime.now(), nextDeparture.time + (nextDeparture.delay ?: Duration.ZERO) - ).toMinutes() - if (timeLeft < 1) "now" else "in $timeLeft min" + ).toMinutes().toInt() + if (timeLeft < 1) + context.getString(R.string.departure_time_now) + else + context.resources.getQuantityString(R.plurals.departure_time_in, timeLeft, timeLeft) } Text( diff --git a/core/i18n/src/main/res/values-de/strings.xml b/core/i18n/src/main/res/values-de/strings.xml index 2874da16..4cb87b8f 100644 --- a/core/i18n/src/main/res/values-de/strings.xml +++ b/core/i18n/src/main/res/values-de/strings.xml @@ -813,4 +813,9 @@ Symbol zurücksetzen Kompakte Tags Beschriftungen oder Symbole von Tags ausblenden um den von Tags eingenommenen Platz zu reduzieren + Sofort + + in einer Minute + in %1$d Minuten + \ No newline at end of file diff --git a/core/i18n/src/main/res/values/strings.xml b/core/i18n/src/main/res/values/strings.xml index 8def4023..dadf6e26 100644 --- a/core/i18n/src/main/res/values/strings.xml +++ b/core/i18n/src/main/res/values/strings.xml @@ -1014,4 +1014,9 @@ Humidity Wind Precipitation + now + + in one minute + in %1$d minutes + \ No newline at end of file