mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-11-06 02:40:58 +01:00
Fix errors when a plural translation is missing (#1716)
## Description Previously not every plural translation had full coverage and some did not have the fallback "other" quantity translation. So for some languages this would cause an error when trying to display the string depending on the quantity. This PR ensures every plural translation has the "other" fallback. Note: the "other" fallback is copied from an existing translation so I'm sure some will not be grammatically correct! Dev note: I used a python script to parse and fix the entries, so it also rewrote some of the unrelated `CDATA` entries. ### Related issues Fixes #1676 ### Testing On the emulator, I reproduced the error in the issue with the Danish translation, verified it was fixed after the patch was applied ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
35c4d13f8f
commit
4f5cd3e7b1
15 changed files with 200 additions and 66 deletions
|
|
@ -5,6 +5,8 @@ import com.github.damontecres.wholphin.R
|
|||
import com.github.damontecres.wholphin.data.ExtrasItem
|
||||
import com.github.damontecres.wholphin.data.model.BaseItem
|
||||
import com.github.damontecres.wholphin.data.pluralRes
|
||||
import com.github.damontecres.wholphin.data.stringRes
|
||||
import com.github.damontecres.wholphin.ui.isNotNullOrBlank
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.userLibraryApi
|
||||
|
|
@ -48,9 +50,10 @@ class ExtrasService
|
|||
if (items.size == 1) {
|
||||
val item = items.first()
|
||||
val title =
|
||||
item.title ?: context.resources.getQuantityString(type.pluralRes, 1)
|
||||
item.title.takeIf { it.isNotNullOrBlank() }
|
||||
?: context.resources.getQuantityString(type.pluralRes, 1)
|
||||
val subtitle =
|
||||
if (item.title == null) {
|
||||
if (item.title.isNotNullOrBlank()) {
|
||||
context.resources.getQuantityString(type.pluralRes, 1)
|
||||
} else {
|
||||
null
|
||||
|
|
@ -64,8 +67,7 @@ class ExtrasService
|
|||
imageUrl = imageUrlService.getItemImageUrl(item, ImageType.PRIMARY),
|
||||
)
|
||||
} else if (items.size > 1) {
|
||||
val title =
|
||||
context.resources.getQuantityString(type.pluralRes, items.size)
|
||||
val title = context.resources.getString(type.stringRes)
|
||||
val subtitle =
|
||||
context.resources.getQuantityString(
|
||||
R.plurals.items,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue