e-hentai language flag (#343)
* add language flag to BrowseList * add Japanese support * show language flag in metadata view
This commit is contained in:
parent
2e0eb6ce85
commit
18b4b071a8
13 changed files with 79 additions and 24 deletions
|
|
@ -53,6 +53,7 @@ import tachiyomi.i18n.sy.SYMR
|
|||
import tachiyomi.presentation.core.components.BadgeGroup
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
import tachiyomi.presentation.core.icons.FlagEmoji.Companion.getEmojiLangFlag
|
||||
import tachiyomi.presentation.core.util.selectedBackground
|
||||
import java.time.Instant
|
||||
import java.time.ZoneId
|
||||
|
|
@ -137,12 +138,21 @@ fun BrowseSourceEHentaiListItem(
|
|||
SYMR.plurals.browse_language_and_pages,
|
||||
pageCount,
|
||||
pageCount,
|
||||
locale.toLanguageTag().uppercase(),
|
||||
// KMK -->
|
||||
getEmojiLangFlag(
|
||||
// KMK <--
|
||||
locale.toLanguageTag(), // KMK: .uppercase()
|
||||
),
|
||||
)
|
||||
} else if (pageCount != null) {
|
||||
context.pluralStringResource(SYMR.plurals.num_pages, pageCount, pageCount)
|
||||
} else {
|
||||
locale?.toLanguageTag()?.uppercase().orEmpty()
|
||||
locale?.toLanguageTag()
|
||||
// KMK -->
|
||||
?.let { getEmojiLangFlag(it) }
|
||||
// .uppercase()
|
||||
// KMK <--
|
||||
.orEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ import eu.kanade.tachiyomi.util.system.copyToClipboard
|
|||
import exh.metadata.MetadataUtil
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import exh.ui.metadata.adapters.MetadataUIUtil.bindDrawable
|
||||
import exh.util.SourceTagsUtil
|
||||
import exh.util.SourceTagsUtil.genreTextColor
|
||||
import tachiyomi.core.common.i18n.pluralStringResource
|
||||
import tachiyomi.core.common.i18n.stringResource
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.i18n.sy.SYMR
|
||||
import tachiyomi.presentation.core.icons.FlagEmoji.Companion.getEmojiLangFlag
|
||||
|
||||
@Composable
|
||||
fun EHentaiDescription(
|
||||
|
|
@ -91,7 +93,14 @@ fun EHentaiDescription(
|
|||
binding.pages.setTextColor(textColor)
|
||||
// KMK <--
|
||||
|
||||
val language = meta.language ?: context.stringResource(MR.strings.unknown)
|
||||
val language = (meta.language ?: context.stringResource(MR.strings.unknown))
|
||||
// KMK -->
|
||||
.let { lang ->
|
||||
getEmojiLangFlag(
|
||||
SourceTagsUtil.getLocaleSourceUtil(lang.lowercase())?.toLanguageTag().orEmpty(),
|
||||
) + " " + lang
|
||||
}
|
||||
// KMK <--
|
||||
binding.language.text = if (meta.translated == true) {
|
||||
context.stringResource(SYMR.strings.language_translated, language)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@ package exh.util
|
|||
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import exh.metadata.metadata.base.RaisedTag
|
||||
import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
|
|
@ -9,6 +14,7 @@ import exh.source.PURURIN_SOURCE_ID
|
|||
import exh.source.TSUMINO_SOURCE_ID
|
||||
import exh.source.mangaDexSourceIds
|
||||
import exh.source.nHentaiSourceIds
|
||||
import tachiyomi.presentation.core.icons.FlagEmoji.Companion.getEmojiLangFlag
|
||||
import java.util.Locale
|
||||
|
||||
object SourceTagsUtil {
|
||||
|
|
@ -122,6 +128,7 @@ object SourceTagsUtil {
|
|||
|
||||
fun getLocaleSourceUtil(language: String?) = when (language) {
|
||||
"english", "eng" -> Locale("en")
|
||||
"japanese" -> Locale("ja")
|
||||
"chinese" -> Locale("zh")
|
||||
"spanish" -> Locale("es")
|
||||
"korean" -> Locale("ko")
|
||||
|
|
@ -142,3 +149,32 @@ object SourceTagsUtil {
|
|||
|
||||
private val spaceRegex = "\\s".toRegex()
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun LanguageFlagPreview() {
|
||||
val locales = listOf(
|
||||
Locale("en"),
|
||||
Locale("ja"),
|
||||
Locale("zh"),
|
||||
Locale("es"),
|
||||
Locale("ko"),
|
||||
Locale("ru"),
|
||||
Locale("fr"),
|
||||
Locale("pt"),
|
||||
Locale("th"),
|
||||
Locale("de"),
|
||||
Locale("it"),
|
||||
Locale("vi"),
|
||||
Locale("pl"),
|
||||
Locale("hu"),
|
||||
Locale("nl"),
|
||||
)
|
||||
Column {
|
||||
FlowRow {
|
||||
locales.forEach {
|
||||
Text(text = getEmojiLangFlag(it.toLanguageTag()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@
|
|||
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d page</item>
|
||||
<item quantity="other">%2$s, %1$d pages</item>
|
||||
<item quantity="one">%2$s %1$d page</item>
|
||||
<item quantity="other">%2$s %1$d pages</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Humanize time -->
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@
|
|||
<item quantity="other">%1$d páginas</item>
|
||||
</plurals>
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d página</item>
|
||||
<item quantity="many">%2$s, %1$d páginas</item>
|
||||
<item quantity="other">%2$s, %1$d páginas</item>
|
||||
<item quantity="one">%2$s %1$d página</item>
|
||||
<item quantity="many">%2$s %1$d páginas</item>
|
||||
<item quantity="other">%2$s %1$d páginas</item>
|
||||
</plurals>
|
||||
<plurals name="humanize_year">
|
||||
<item quantity="one">hace %1$d año</item>
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@
|
|||
<item quantity="other">%1$d na mga pahina</item>
|
||||
</plurals>
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d na pahina</item>
|
||||
<item quantity="other">%2$s, %1$d na mga pahina</item>
|
||||
<item quantity="one">%2$s %1$d na pahina</item>
|
||||
<item quantity="other">%2$s %1$d na mga pahina</item>
|
||||
</plurals>
|
||||
<plurals name="humanize_year">
|
||||
<item quantity="one">%1$d taon ang nakalipas</item>
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d page</item>
|
||||
<item quantity="other">%2$s, %1$d pages</item>
|
||||
<item quantity="one">%2$s %1$d page</item>
|
||||
<item quantity="other">%2$s %1$d pages</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Humanize time -->
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@
|
|||
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d page</item>
|
||||
<item quantity="other">%2$s, %1$d pages</item>
|
||||
<item quantity="one">%2$s %1$d page</item>
|
||||
<item quantity="other">%2$s %1$d pages</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Humanize time -->
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@
|
|||
</plurals>
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d ページ</item>
|
||||
<item quantity="other">%2$s, %1$d ページ</item>
|
||||
<item quantity="one">%2$s %1$d ページ</item>
|
||||
<item quantity="other">%2$s %1$d ページ</item>
|
||||
</plurals>
|
||||
<!-- Humanize time -->
|
||||
<plurals name="humanize_year">
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@
|
|||
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d página</item>
|
||||
<item quantity="other">%2$s, %1$d páginas</item>
|
||||
<item quantity="one">%2$s %1$d página</item>
|
||||
<item quantity="other">%2$s %1$d páginas</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Humanize time -->
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@
|
|||
</plurals>
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="one">%2$s, %1$d страница</item>
|
||||
<item quantity="few">%2$s, %1$d страницы</item>
|
||||
<item quantity="many">%2$s, %1$d страниц</item>
|
||||
<item quantity="other">%2$s, %1$d страниц</item>
|
||||
<item quantity="one">%2$s %1$d страница</item>
|
||||
<item quantity="few">%2$s %1$d страницы</item>
|
||||
<item quantity="many">%2$s %1$d страниц</item>
|
||||
<item quantity="other">%2$s %1$d страниц</item>
|
||||
</plurals>
|
||||
<!-- Humanize time -->
|
||||
<plurals name="humanize_year">
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="other">%2$s, %1$d 页</item>
|
||||
<item quantity="other">%2$s %1$d 页</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Humanize time -->
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<!-- Enhanced E/ExHentai Browse View -->
|
||||
<plurals name="browse_language_and_pages">
|
||||
<item quantity="other">%2$s, %1$d 頁</item>
|
||||
<item quantity="other">%2$s %1$d 頁</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Humanize time -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue