Add localized duration formatting and related string resources (#1571)

## Description
Instead of using English-only duration format (e.g. `HHh MMm SSs`) in
various places, I've added a format function that is based on several
new localized resources keys.

That includes:
1. Media runtime in Item view
2. Time remaining in Item view
3. End time in Player view
4. Time passed and time remained in Player view

### Related issues
None

### Testing
I installed the app on my Google TV Streamer, switched to my language,
browsed all item views that I could think of to see that the duration
labels are all localized in my language. I didn't commit those strings,
I will do it through the Weblate after it will get merged. I also played
a few items and saw that the labels there are localized as well.

## Screenshots
It looks the same in English as before, currently no other language has
custom resources for it yet.

## AI or LLM usage
Used Claude Sonnet to detect places that I missed that are related to
this localization change. Also it helped me to get access to my format
function from various places in the code.

---------

Co-authored-by: Damontecres <damontecres@gmail.com>
This commit is contained in:
Tal Sarid 2026-07-06 15:43:06 +03:00 • committed by GitHub
parent 1d7ddd713b
commit f6e00c7820
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 86 additions and 25 deletions

View file

@ -5,12 +5,15 @@ import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString
import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.WholphinApplication
import com.github.damontecres.wholphin.ui.abbreviateNumber
import com.github.damontecres.wholphin.ui.detail.CardGridItem
import com.github.damontecres.wholphin.ui.detail.music.artistsString
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
import com.github.damontecres.wholphin.ui.dot
import com.github.damontecres.wholphin.ui.formatDateTime
import com.github.damontecres.wholphin.ui.formatDuration
import com.github.damontecres.wholphin.ui.getDateFormatter
import com.github.damontecres.wholphin.ui.joinNotBlank
import com.github.damontecres.wholphin.ui.nav.Destination
@ -161,10 +164,18 @@ data class BaseItem(
?.ticks
?.roundMinutes
?.takeIf { it > Duration.ZERO }
?.let { add(it.toString()) }
?.let { add(WholphinApplication.instance.resources.formatDuration(it)) }
data.timeRemaining
?.roundMinutes
?.let { add("$it left") }
?.let {
val resources = WholphinApplication.instance.resources
add(
resources.getString(
R.string.time_left,
resources.formatDuration(it),
),
)
}
}
details.forEachIndexed { index, string ->
append(string)