From 8433be8d50e96da44d4cfe22b79a6840a630c7f0 Mon Sep 17 00:00:00 2001 From: Jonas Kalderstam Date: Sat, 25 Nov 2023 13:54:50 +0100 Subject: [PATCH] Changed word/minutes to plural strings --- .../feeder/ui/compose/feed/FeedItemCard.kt | 21 +++++++++++-------- .../ui/compose/feedarticle/ReaderView.kt | 11 +++++----- app/src/main/res/values-sv/strings.xml | 2 -- app/src/main/res/values/plural_strings.xml | 16 ++++++++++++++ app/src/main/res/values/strings.xml | 14 +++++++++++-- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt index bad6c1199..661144216 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feed/FeedItemCard.kt @@ -32,6 +32,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextOverflow @@ -289,12 +290,14 @@ fun RowScope.FeedItemText( } if (readTimeSecs > 0) { CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) { - val readTimeText = stringResource( - id = R.string.n_reading_time, - readTimeSecs / 60, - readTimeSecs % 60, - ) - val wordCountText = stringResource(id = R.string.n_words_short, item.wordCount) + val readTimeText = + pluralStringResource(id = R.plurals.n_minutes, count = readTimeSecs / 60) + .format( + "${readTimeSecs / 60}:${readTimeSecs % 60}", + ) + val wordCountText = + pluralStringResource(id = R.plurals.n_words, count = item.wordCount) + .format(item.wordCount) Row( horizontalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier @@ -343,7 +346,7 @@ private fun Preview() { feedImageUrl = null, primarySortTime = Instant.EPOCH, rawPubDate = null, - wordCount = 900, + wordCount = 588, ), showThumbnail = true, onMarkAboveAsRead = {}, @@ -381,7 +384,7 @@ private fun PreviewWithImageUnread() { feedImageUrl = URL("https://foo/bar.png"), primarySortTime = Instant.EPOCH, rawPubDate = null, - wordCount = 900, + wordCount = 939, ), showThumbnail = true, onMarkAboveAsRead = {}, @@ -420,7 +423,7 @@ private fun PreviewWithImageRead() { feedImageUrl = null, primarySortTime = Instant.EPOCH, rawPubDate = null, - wordCount = 900, + wordCount = 950, ), showThumbnail = true, onMarkAboveAsRead = {}, diff --git a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt index 81584fb6b..aec68d6f8 100644 --- a/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt +++ b/app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ReaderView.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.CustomAccessibilityAction import androidx.compose.ui.semantics.clearAndSetSemantics @@ -193,11 +194,11 @@ fun ReaderView( imageVector = Icons.Outlined.Timelapse, contentDescription = null, ) - val readTimeText = stringResource( - id = R.string.n_reading_time, - readTimeSecs / 60, - readTimeSecs % 60, - ) + val readTimeText = + pluralStringResource(id = R.plurals.n_minutes, count = readTimeSecs / 60) + .format( + "${readTimeSecs / 60}:${readTimeSecs % 60}", + ) WithBidiDeterminedLayoutDirection(paragraph = readTimeText) { val interactionSource = remember { MutableInteractionSource() } diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 8aabfa312..e9ea26ce4 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -229,7 +229,5 @@ Läsplatta Lägg till ändå Öppna webbläsare i delad skärm - %1$d ord - %1$d minuter %2$d sekunder Visa uppskattad lästid diff --git a/app/src/main/res/values/plural_strings.xml b/app/src/main/res/values/plural_strings.xml index 78ba1670f..645085b3b 100644 --- a/app/src/main/res/values/plural_strings.xml +++ b/app/src/main/res/values/plural_strings.xml @@ -24,4 +24,20 @@ @string/many_tags @string/other_tags + + @string/zero_words + @string/one_word + @string/two_words + @string/few_words + @string/many_words + @string/other_words + + + @string/zero_minutes + @string/one_minute + @string/two_minutes + @string/few_minutes + @string/many_minutes + @string/other_minutes + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6c198a40e..cb1ce49fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -242,7 +242,17 @@ No URL Add anyway Open browser in split screen - %1$d words - %1$d minutes %2$d seconds Show estimated reading time + %1$s words + %1$s word + %1$s words + %1$s words + %1$s words + %1$s words + %1$s minutes + %1$s minute + %1$s minutes + %1$s minutes + %1$s minutes + %1$s minutes