diff --git a/app/src/main/java/com/nuvio/tv/ui/screens/library/LibraryScreen.kt b/app/src/main/java/com/nuvio/tv/ui/screens/library/LibraryScreen.kt index c7b34691..ce370dce 100644 --- a/app/src/main/java/com/nuvio/tv/ui/screens/library/LibraryScreen.kt +++ b/app/src/main/java/com/nuvio/tv/ui/screens/library/LibraryScreen.kt @@ -79,6 +79,7 @@ import com.nuvio.tv.ui.components.NuvioDialog import com.nuvio.tv.ui.theme.NuvioColors import com.nuvio.tv.ui.theme.NuvioTheme import com.nuvio.tv.ui.util.formatAddonTypeLabel +import com.nuvio.tv.ui.util.localizedGenreLabel import kotlinx.coroutines.delay import androidx.compose.ui.res.stringResource import com.nuvio.tv.R @@ -427,7 +428,7 @@ private fun LibrarySelectorsRow( } ?: stringResource(R.string.library_type_all) val selectedSortLabel = stringResource(selectedSortOption.labelResId) val allLabel = stringResource(R.string.library_type_all) - val selectedGenreLabel = selectedGenre ?: allLabel + val selectedGenreLabel = selectedGenre?.let { localizedGenreLabel(it) } ?: allLabel val selectedYearLabel = selectedYear ?: allLabel Column( @@ -509,7 +510,7 @@ private fun LibrarySelectorsRow( selectedValue = selectedGenre ?: "__all__", expanded = expandedPicker == "genre", options = listOf(genreAllOption) + genres.map { - LibraryOption("${it.label} (${it.count})", it.key) + LibraryOption("${localizedGenreLabel(it.label)} (${it.count})", it.key) }, onExpandedChange = { onExpandedChange("genre", it) }, onSelect = { option -> diff --git a/app/src/main/java/com/nuvio/tv/ui/screens/search/SearchDiscoverSection.kt b/app/src/main/java/com/nuvio/tv/ui/screens/search/SearchDiscoverSection.kt index c7c893eb..ffca71f0 100644 --- a/app/src/main/java/com/nuvio/tv/ui/screens/search/SearchDiscoverSection.kt +++ b/app/src/main/java/com/nuvio/tv/ui/screens/search/SearchDiscoverSection.kt @@ -63,6 +63,7 @@ import com.nuvio.tv.ui.components.LoadingIndicator import com.nuvio.tv.ui.components.PosterCardStyle import com.nuvio.tv.ui.theme.NuvioColors import com.nuvio.tv.ui.util.formatAddonTypeLabel +import com.nuvio.tv.ui.util.localizedGenreLabel @OptIn(ExperimentalTvMaterial3Api::class) @Composable @@ -100,7 +101,7 @@ internal fun DiscoverSection( } val selectedTypeLabel = localizedTypeLabel(uiState.selectedDiscoverType) val selectedCatalogLabel = selectedCatalog?.catalogName ?: stringResource(R.string.discover_select_catalog) - val selectedGenreLabel = uiState.selectedDiscoverGenre ?: stringResource(R.string.discover_genre_default) + val selectedGenreLabel = uiState.selectedDiscoverGenre?.let { localizedGenreLabel(it) } ?: stringResource(R.string.discover_genre_default) Column( modifier = modifier @@ -161,7 +162,7 @@ internal fun DiscoverSection( expanded = expandedPicker == "genre", options = buildList { add(DiscoverOption(stringResource(R.string.discover_genre_default), "__default__")) - addAll(genres.map { DiscoverOption(it, it) }) + addAll(genres.map { DiscoverOption(localizedGenreLabel(it), it) }) }, onExpandedChange = { shouldExpand -> expandedPicker = if (shouldExpand) "genre" else null @@ -181,7 +182,7 @@ internal fun DiscoverSection( .takeIf { it.isNotEmpty() } ?.let(::add) } - uiState.selectedDiscoverGenre?.let(::add) + uiState.selectedDiscoverGenre?.let { add(localizedGenreLabel(it)) } } Text( text = metadataSegments.joinToString(" • "), diff --git a/app/src/main/java/com/nuvio/tv/ui/util/GenreLabelFormatter.kt b/app/src/main/java/com/nuvio/tv/ui/util/GenreLabelFormatter.kt new file mode 100644 index 00000000..a592fc6a --- /dev/null +++ b/app/src/main/java/com/nuvio/tv/ui/util/GenreLabelFormatter.kt @@ -0,0 +1,37 @@ +package com.nuvio.tv.ui.util + +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource +import com.nuvio.tv.R + +@Composable +fun localizedGenreLabel(genre: String): String = when (genre.lowercase().trim()) { + "action" -> stringResource(R.string.genre_action) + "adventure" -> stringResource(R.string.genre_adventure) + "animation" -> stringResource(R.string.genre_animation) + "comedy" -> stringResource(R.string.genre_comedy) + "crime" -> stringResource(R.string.genre_crime) + "documentary" -> stringResource(R.string.genre_documentary) + "drama" -> stringResource(R.string.genre_drama) + "family" -> stringResource(R.string.genre_family) + "fantasy" -> stringResource(R.string.genre_fantasy) + "history" -> stringResource(R.string.genre_history) + "horror" -> stringResource(R.string.genre_horror) + "music" -> stringResource(R.string.genre_music) + "mystery" -> stringResource(R.string.genre_mystery) + "romance" -> stringResource(R.string.genre_romance) + "science fiction" -> stringResource(R.string.genre_science_fiction) + "tv movie" -> stringResource(R.string.genre_tv_movie) + "thriller" -> stringResource(R.string.genre_thriller) + "war" -> stringResource(R.string.genre_war) + "western" -> stringResource(R.string.genre_western) + "action & adventure" -> stringResource(R.string.genre_action_adventure) + "kids" -> stringResource(R.string.genre_kids) + "news" -> stringResource(R.string.genre_news) + "reality" -> stringResource(R.string.genre_reality) + "sci-fi & fantasy" -> stringResource(R.string.genre_sci_fi_fantasy) + "soap" -> stringResource(R.string.genre_soap) + "talk" -> stringResource(R.string.genre_talk) + "war & politics" -> stringResource(R.string.genre_war_politics) + else -> genre +}