Fix strings missing from translations (#959)

## Description
Weblate's Android string parser (aka
https://translate.codeberg.org/projects/wholphin/) doesn't support
direct translations of string arrays.

Many of Wholphin's preference options are defined in string arrays and
therefore could not be translated. So this PR implements the [suggested
workaround](https://docs.weblate.org/en/latest/formats/android.html) to
move the string into individual entries and reference them in arrays.

Also moves some hardcoded strings into `strings.xml` so they can be
translated. Note: virtually all error messages are still hardcoded, but
they are only for exceptional cases, so it's probably not a huge
problem.

A minor bug where the backdrop would show briefly after switching users
is fixed.

### Related issues
Fixes #957

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Ray 2026-02-23 11:17:57 -05:00 committed by GitHub
parent a44fad890f
commit 2a371e7d6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 156 additions and 93 deletions

View file

@ -123,6 +123,9 @@ class MainActivity : AppCompatActivity() {
@Inject @Inject
lateinit var suggestionsSchedulerService: SuggestionsSchedulerService lateinit var suggestionsSchedulerService: SuggestionsSchedulerService
@Inject
lateinit var backdropService: BackdropService
// Note: unused but injected to ensure it is created // Note: unused but injected to ensure it is created
@Inject @Inject
lateinit var serverEventListener: ServerEventListener lateinit var serverEventListener: ServerEventListener
@ -247,6 +250,9 @@ class MainActivity : AppCompatActivity() {
} }
is SetupDestination.AppContent -> { is SetupDestination.AppContent -> {
LaunchedEffect(Unit) {
backdropService.clearBackdrop()
}
val current = key.current val current = key.current
ProvideLocalClock { ProvideLocalClock {
if (UpdateChecker.ACTIVE && appPreferences.autoCheckForUpdates) { if (UpdateChecker.ACTIVE && appPreferences.autoCheckForUpdates) {

View file

@ -5,6 +5,7 @@ import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.buildAnnotatedString
import com.github.damontecres.wholphin.R import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.WholphinApplication
import org.jellyfin.sdk.model.api.BaseItemDto import org.jellyfin.sdk.model.api.BaseItemDto
import org.jellyfin.sdk.model.api.MediaSegmentType import org.jellyfin.sdk.model.api.MediaSegmentType
import timber.log.Timber import timber.log.Timber
@ -76,7 +77,7 @@ val BaseItemDto.seriesProductionYears: String?
append(productionYear.toString()) append(productionYear.toString())
if (status == "Continuing") { if (status == "Continuing") {
append(" - ") append(" - ")
append("Present") append(WholphinApplication.instance.getString(R.string.series_continueing))
} else if (status == "Ended") { } else if (status == "Ended") {
endDate?.let { endDate?.let {
if (it.year != productionYear) { if (it.year != productionYear) {

View file

@ -857,7 +857,7 @@ fun CollectionFolderGridContent(
DataLoadingState.Loading, DataLoadingState.Loading,
-> { -> {
// This shouldn't happen, so just show placeholder // This shouldn't happen, so just show placeholder
Text("Loading") Text(stringResource(R.string.loading))
} }
is DataLoadingState.Error -> { is DataLoadingState.Error -> {

View file

@ -102,7 +102,7 @@ fun DownloadSubtitlesContent(
.padding(PaddingValues(24.dp)), .padding(PaddingValues(24.dp)),
) { ) {
Text( Text(
text = "Search & download subtitles", text = stringResource(R.string.search_and_download_subtitles),
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )
@ -113,7 +113,7 @@ fun DownloadSubtitlesContent(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Text( Text(
text = "Language", text = stringResource(R.string.language),
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )
@ -137,7 +137,7 @@ fun DownloadSubtitlesContent(
} }
if (dialogItems.isEmpty()) { if (dialogItems.isEmpty()) {
Text( Text(
text = "No remote subtitles were found", text = stringResource(R.string.no_subtitles_found),
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )

View file

@ -1,6 +1,7 @@
package com.github.damontecres.wholphin.ui.playback package com.github.damontecres.wholphin.ui.playback
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.preferences.PrefContentScale import com.github.damontecres.wholphin.preferences.PrefContentScale
import org.jellyfin.sdk.model.api.BaseItemKind import org.jellyfin.sdk.model.api.BaseItemKind
import org.jellyfin.sdk.model.api.CollectionType import org.jellyfin.sdk.model.api.CollectionType
@ -9,13 +10,13 @@ val playbackSpeedOptions = listOf(".25", ".5", ".75", "1.0", "1.25", "1.5", "1.7
val playbackScaleOptions = val playbackScaleOptions =
mapOf( mapOf(
ContentScale.Fit to "Fit", ContentScale.Fit to R.string.content_scale_fit,
ContentScale.None to "None", ContentScale.None to R.string.none,
ContentScale.Crop to "Crop", ContentScale.Crop to R.string.content_scale_crop,
// ContentScale.Inside to "Inside", // ContentScale.Inside to "Inside",
ContentScale.FillBounds to "Fill", ContentScale.FillBounds to R.string.content_scale_fill,
ContentScale.FillWidth to "Fill Width", ContentScale.FillWidth to R.string.content_scale_fill_width,
ContentScale.FillHeight to "Fill Height", ContentScale.FillHeight to R.string.content_scale_fill_height,
) )
val PrefContentScale.scale: ContentScale val PrefContentScale.scale: ContentScale

View file

@ -144,7 +144,9 @@ fun PlaybackDialog(
BottomDialogItem( BottomDialogItem(
data = PlaybackDialogType.VIDEO_SCALE, data = PlaybackDialogType.VIDEO_SCALE,
headline = stringResource(R.string.video_scale), headline = stringResource(R.string.video_scale),
supporting = playbackScaleOptions[settings.contentScale], supporting =
playbackScaleOptions[settings.contentScale]
?.let { stringResource(it) },
), ),
) )
} }
@ -220,7 +222,7 @@ fun PlaybackDialog(
playbackScaleOptions.map { (scale, name) -> playbackScaleOptions.map { (scale, name) ->
BottomDialogItem( BottomDialogItem(
data = scale, data = scale,
headline = name, headline = stringResource(name),
supporting = null, supporting = null,
) )
} }

View file

@ -62,7 +62,7 @@ fun AddSeerrServerApiKey(
val passwordFocusRequester = remember { FocusRequester() } val passwordFocusRequester = remember { FocusRequester() }
LaunchedEffect(Unit) { focusRequester.tryRequestFocus() } LaunchedEffect(Unit) { focusRequester.tryRequestFocus() }
Text( Text(
text = "Enter URL & API Key", text = stringResource(R.string.enter_url_api_key),
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
@ -73,7 +73,7 @@ fun AddSeerrServerApiKey(
modifier = Modifier.align(Alignment.CenterHorizontally), modifier = Modifier.align(Alignment.CenterHorizontally),
) { ) {
Text( Text(
text = "URL", text = stringResource(R.string.url),
modifier = Modifier.padding(end = 8.dp), modifier = Modifier.padding(end = 8.dp),
) )
EditTextBox( EditTextBox(
@ -104,7 +104,7 @@ fun AddSeerrServerApiKey(
modifier = Modifier.align(Alignment.CenterHorizontally), modifier = Modifier.align(Alignment.CenterHorizontally),
) { ) {
Text( Text(
text = "API Key", text = stringResource(R.string.api_key),
modifier = Modifier.padding(end = 8.dp), modifier = Modifier.padding(end = 8.dp),
) )
EditTextBox( EditTextBox(

View file

@ -6,6 +6,8 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.res.stringResource
import com.github.damontecres.wholphin.R
import com.github.damontecres.wholphin.data.model.SeerrAuthMethod import com.github.damontecres.wholphin.data.model.SeerrAuthMethod
import com.github.damontecres.wholphin.ui.components.BasicDialog import com.github.damontecres.wholphin.ui.components.BasicDialog
import com.github.damontecres.wholphin.ui.components.DialogItem import com.github.damontecres.wholphin.ui.components.DialogItem
@ -71,27 +73,26 @@ fun ChooseSeerrLoginType(
onChoose: (SeerrAuthMethod) -> Unit, onChoose: (SeerrAuthMethod) -> Unit,
) { ) {
val params = val params =
remember { DialogParams(
DialogParams( fromLongClick = false,
fromLongClick = false, title = stringResource(R.string.seerr_login),
title = "Login to Seerr server", items =
items = listOf(
listOf( DialogItem(
DialogItem( text = stringResource(R.string.api_key),
text = "API Key", onClick = { onChoose.invoke(SeerrAuthMethod.API_KEY) },
onClick = { onChoose.invoke(SeerrAuthMethod.API_KEY) },
),
DialogItem(
text = "Jellyfin user",
onClick = { onChoose.invoke(SeerrAuthMethod.JELLYFIN) },
),
DialogItem(
text = "Local user",
onClick = { onChoose.invoke(SeerrAuthMethod.LOCAL) },
),
), ),
) DialogItem(
} text = stringResource(R.string.seerr_jellyfin_user),
onClick = { onChoose.invoke(SeerrAuthMethod.JELLYFIN) },
),
DialogItem(
text = stringResource(R.string.seerr_local_user),
onClick = { onChoose.invoke(SeerrAuthMethod.LOCAL) },
),
),
)
DialogPopup( DialogPopup(
params = params, params = params,
onDismissRequest = onDismissRequest, onDismissRequest = onDismissRequest,

View file

@ -522,109 +522,161 @@
<string name="display_presets">Display presets</string> <string name="display_presets">Display presets</string>
<string name="display_presets_description">Built-in presets to quickly style all rows</string> <string name="display_presets_description">Built-in presets to quickly style all rows</string>
<string name="customize_home_summary">Choose rows and images on the home page</string> <string name="customize_home_summary">Choose rows and images on the home page</string>
<string name="content_scale_fit">Fit</string>
<string name="content_scale_crop">Crop</string>
<string name="content_scale_fill">Fill</string>
<string name="content_scale_fill_width">Fill width</string>
<string name="content_scale_fill_height">Fill height</string>
<string name="display_preset_default">Wholphin Default</string> <string name="display_preset_default">Wholphin Default</string>
<string name="display_preset_compact">Wholphin Compact</string> <string name="display_preset_compact">Wholphin Compact</string>
<string name="display_preset_series_thumb">Series Thumb images</string> <string name="display_preset_series_thumb">Series Thumb images</string>
<string name="display_preset_episode_thumbnails">Episode Thumbnail images</string> <string name="display_preset_episode_thumbnails">Episode Thumbnail images</string>
<string name="volume_lowest">Lowest</string>
<string name="volume_low">Low</string>
<string name="volume_medium">Medium</string>
<string name="volume_high">High</string>
<string name="volume_full">Full</string>
<string-array name="theme_song_volume"> <string-array name="theme_song_volume">
<item>Disabled</item> <item>@string/disabled</item>
<item>Lowest</item> <item>@string/volume_lowest</item>
<item>Low</item> <item>@string/volume_low</item>
<item>Medium</item> <item>@string/volume_medium</item>
<item>High</item> <item>@string/volume_high</item>
<item>Full</item> <item>@string/volume_full</item>
</string-array> </string-array>
<string name="purple">Purple</string>
<string name="orange">Orange</string>
<string name="bold_blue">Bold Blue</string>
<string name="black">Black</string>
<string-array name="app_theme_colors"> <string-array name="app_theme_colors">
<item>Purple</item> <item>@string/purple</item>
<item>Blue</item> <item>@string/blue</item>
<item>Green</item> <item>@string/green</item>
<item>Orange</item> <item>@string/orange</item>
<item>Bold Blue</item> <item>@string/bold_blue</item>
<item>Black</item> <item>@string/black</item>
</string-array> </string-array>
<string name="skip_ignore">Ignore</string>
<string name="skip_automatically">Skip automatically</string>
<string name="skip_ask">Ask to skip</string>
<string-array name="skip_behaviors"> <string-array name="skip_behaviors">
<item>Ignore</item> <item>@string/skip_ignore</item>
<item>Skip automatically</item> <item>@string/skip_automatically</item>
<item>Ask to skip</item> <item>@string/skip_ask</item>
</string-array> </string-array>
<string-array name="content_scale"> <string-array name="content_scale">
<item>Fit</item> <item>@string/content_scale_fit</item>
<item>None</item> <item>@string/none</item>
<item>Crop</item> <item>@string/content_scale_crop</item>
<item>Fill</item> <item>@string/content_scale_fill</item>
<item>Fill Width</item> <item>@string/content_scale_fill_width</item>
<item>Fill Height</item> <item>@string/content_scale_fill_height</item>
</string-array> </string-array>
<string name="ffmpeg_fallback">Only use FFmpeg if no built-in decoder exists</string>
<string name="ffmpeg_prefer">Prefer to use FFmpeg over built-in decoders</string>
<string name="ffmpeg_never">Never use FFmpeg decoders</string>
<string-array name="ffmpeg_extension_options"> <string-array name="ffmpeg_extension_options">
<item>Only use FFmpeg if no built-in decoder exists</item> <item>@string/ffmpeg_fallback</item>
<item>Prefer to use FFmpeg over built-in decoders</item> <item>@string/ffmpeg_prefer</item>
<item>Never use FFmpeg decoders</item> <item>@string/ffmpeg_never</item>
</string-array> </string-array>
<string name="next_up_playback_end">At the end of playback</string>
<string name="next_up_outro">During end credits/outro</string>
<string-array name="show_next_up_when_options"> <string-array name="show_next_up_when_options">
<item>At the end of playback</item> <item>@string/next_up_playback_end</item>
<item>During end credits/outro</item> <item>@string/next_up_outro</item>
</string-array> </string-array>
<string name="white">White</string>
<string name="light_gray">Light gray</string>
<string name="dark_gray">Dark gray</string>
<string name="yellow">Yellow</string>
<string name="cyan">Cyan</string>
<string name="magenta">Magenta</string>
<string-array name="font_colors"> <string-array name="font_colors">
<item>White</item> <item>@string/white</item>
<item>Black</item> <item>@string/black</item>
<item>Light Gray</item> <item>@string/light_gray</item>
<item>Dark Gray</item> <item>@string/dark_gray</item>
<item>Red</item> <item>@string/red</item>
<item>Yellow</item> <item>@string/yellow</item>
<item>Green</item> <item>@string/green</item>
<item>Cyan</item> <item>@string/cyan</item>
<item>Blue</item> <item>@string/blue</item>
<item>Magenta</item> <item>@string/magenta</item>
</string-array> </string-array>
<string name="subtitle_edge_outline">Outline</string>
<string name="subtitle_edge_shadow">Shadow</string>
<string-array name="subtitle_edge"> <string-array name="subtitle_edge">
<item>None</item> <item>@string/none</item>
<item>Outline</item> <item>@string/subtitle_edge_outline</item>
<item>Shadow</item> <item>@string/subtitle_edge_shadow</item>
</string-array> </string-array>
<string name="background_style_wrap">Wrap</string>
<string name="background_style_boxed">Boxed</string>
<string-array name="background_style"> <string-array name="background_style">
<item>None</item> <item>@string/none</item>
<item>Wrap</item> <item>@string/background_style_wrap</item>
<item>Boxed</item> <item>@string/background_style_boxed</item>
</string-array> </string-array>
<string name="exoplayer" translatable="false">ExoPlayer</string>
<string name="mpv" translatable="false">MPV</string>
<string name="prefer_mpv">Prefer MPV</string>
<string-array name="player_backend_options"> <string-array name="player_backend_options">
<item>ExoPlayer</item> <item>@string/exoplayer</item>
<item>MPV</item> <item>@string/mpv</item>
<item>Prefer MPV</item> <item>@string/prefer_mpv</item>
</string-array> </string-array>
<string name="player_backend_options_subtitles_prefer_mpv">Use ExoPlayer for HDR playback</string>
<string-array name="player_backend_options_subtitles"> <string-array name="player_backend_options_subtitles">
<item /> <item /><!-- Intentionally blank -->
<item /> <item /><!-- Intentionally blank -->
<item>Use ExoPlayer for HDR playback</item> <item>@string/player_backend_options_subtitles_prefer_mpv</item>
</string-array> </string-array>
<string name="aspect_ratios_poster">Poster (2:3)</string>
<string name="aspect_ratios_16_9">16:9</string>
<string name="aspect_ratios_4_3">4:3</string>
<string name="aspect_ratios_square">Square (1:1)</string>
<string-array name="aspect_ratios"> <string-array name="aspect_ratios">
<item>Poster (2:3)</item> <item>@string/aspect_ratios_poster</item>
<item>16:9</item> <item>@string/aspect_ratios_16_9</item>
<item>4:3</item> <item>@string/aspect_ratios_4_3</item>
<item>Square (1:1)</item> <item>@string/aspect_ratios_square</item>
</string-array> </string-array>
<string name="image_type_primary">Primary</string>
<string name="image_type_thumb">Thumbary</string>
<string-array name="image_types"> <string-array name="image_types">
<item>Primary</item> <item>@string/image_type_primary</item>
<item>Thumb</item> <item>@string/image_type_thumb</item>
<!-- <item>Banner</item>--> <!-- <item>Banner</item>-->
</string-array> </string-array>
<string name="backdrop_style_dynamic">Image with dynamic color</string>
<string name="backdrop_style_image">Image only</string>
<string name="enter_url_api_key"><![CDATA[Enter URL & API Key]]></string>
<string name="api_key">API Key</string>
<string name="seerr_login">Login to Seerr server</string>
<string name="seerr_jellyfin_user">Jellyfin user</string>
<string name="seerr_local_user">Local user</string>
<string name="search_and_download_subtitles"><![CDATA[Search & download subtitles]]></string>
<string name="no_subtitles_found">No remote subtitles were found</string>
<string name="series_continueing">Present</string>
<string-array name="backdrop_style_options"> <string-array name="backdrop_style_options">
<item>Image with dynamic color</item> <item>@string/backdrop_style_dynamic</item>
<item>Image only</item> <item>@string/backdrop_style_image</item>
<item>None</item> <item>@string/none</item>
</string-array> </string-array>
</resources> </resources>