Fix the Chinese translation in Bilibili (#10136)

* Fix the Chinese translation in Bilibili.

* Rename the Chinese source class name.
This commit is contained in:
Alessandro Jean 2021-12-19 09:05:07 -03:00 committed by GitHub
parent 74ef573bd3
commit cb22cf119e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 30 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'BILIBILI'
pkgNameSuffix = 'all.bilibili'
extClass = '.BilibiliFactory'
extVersionCode = 2
extVersionCode = 3
}
dependencies {

View File

@ -18,7 +18,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.add
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import okhttp3.Headers
@ -77,9 +76,11 @@ abstract class Bilibili(
"were filtered out from the chapter list. Use the BILIBILI website or the official app " +
"to read them for now."
protected open val resolutionPrefTitle: String = "Chapter image resolution"
protected open val imageQualityPrefTitle: String = "Chapter image quality"
protected open val imagePrefTitle: String = "Chapter image format"
protected open val imageQualityPrefEntries: Array<String> = arrayOf("Raw", "HD", "SD")
protected open val imageFormatPrefTitle: String = "Chapter image format"
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
@ -87,8 +88,8 @@ abstract class Bilibili(
private val json: Json by injectLazy()
private val chapterImageResolution: String
get() = preferences.getString("${RESOLUTION_PREF_KEY}_$lang", RESOLUTION_PREF_DEFAULT_VALUE)!!
private val chapterImageQuality: String
get() = preferences.getString("${IMAGE_QUALITY_PREF_KEY}_$lang", IMAGE_QUALITY_PREF_DEFAULT_VALUE)!!
private val chapterImageFormat: String
get() = preferences.getString("${IMAGE_FORMAT_PREF_KEY}_$lang", IMAGE_FORMAT_PREF_DEFAULT_VALUE)!!
@ -342,7 +343,8 @@ abstract class Bilibili(
}
private fun chapterFromObject(episode: BilibiliEpisodeDto, comicId: Int): SChapter = SChapter.create().apply {
name = episodePrefix + episode.shortTitle + " - " + episode.title
name = episodePrefix + episode.shortTitle +
(if (episode.title.isNotBlank()) " - " + episode.title else "")
date_upload = episode.publicationTime.substringBefore("T").toDate()
url = "/mc$comicId/${episode.id}"
}
@ -376,7 +378,7 @@ abstract class Bilibili(
return emptyList()
}
val imageQuality = chapterImageResolution
val imageQuality = chapterImageQuality
val imageFormat = chapterImageFormat
val imageUrls = result.data!!.images.map { "${it.path}@$imageQuality.$imageFormat" }
@ -409,12 +411,12 @@ abstract class Bilibili(
override fun imageUrlParse(response: Response): String = ""
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val resolutionPref = ListPreference(screen.context).apply {
key = "${RESOLUTION_PREF_KEY}_$lang"
title = resolutionPrefTitle
entries = RESOLUTION_PREF_ENTRIES
entryValues = RESOLUTION_PREF_ENTRY_VALUES
setDefaultValue(RESOLUTION_PREF_DEFAULT_VALUE)
val imageQualityPref = ListPreference(screen.context).apply {
key = "${IMAGE_QUALITY_PREF_KEY}_$lang"
title = imageQualityPrefTitle
entries = imageQualityPrefEntries
entryValues = IMAGE_QUALITY_PREF_ENTRY_VALUES
setDefaultValue(IMAGE_QUALITY_PREF_DEFAULT_VALUE)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
@ -423,14 +425,14 @@ abstract class Bilibili(
val entry = entryValues[index] as String
preferences.edit()
.putString("${RESOLUTION_PREF_KEY}_$lang", entry)
.putString("${IMAGE_QUALITY_PREF_KEY}_$lang", entry)
.commit()
}
}
val imageFormatPref = ListPreference(screen.context).apply {
key = "${IMAGE_FORMAT_PREF_KEY}_$lang"
title = imagePrefTitle
title = imageFormatPrefTitle
entries = IMAGE_FORMAT_PREF_ENTRIES
entryValues = IMAGE_FORMAT_PREF_ENTRY_VALUES
setDefaultValue(IMAGE_FORMAT_PREF_DEFAULT_VALUE)
@ -447,7 +449,7 @@ abstract class Bilibili(
}
}
screen.addPreference(resolutionPref)
screen.addPreference(imageQualityPref)
screen.addPreference(imageFormatPref)
}
@ -527,10 +529,9 @@ abstract class Bilibili(
const val PREFIX_ID_SEARCH = "id:"
private val ID_SEARCH_PATTERN = "^id:(mc)?(\\d+)$".toRegex()
private const val RESOLUTION_PREF_KEY = "chapterImageResolution"
private val RESOLUTION_PREF_ENTRIES = arrayOf("Raw", "HD", "SD")
private val RESOLUTION_PREF_ENTRY_VALUES = arrayOf("1200w", "800w", "600w_50q")
private val RESOLUTION_PREF_DEFAULT_VALUE = RESOLUTION_PREF_ENTRY_VALUES[0]
private const val IMAGE_QUALITY_PREF_KEY = "chapterImageResolution"
private val IMAGE_QUALITY_PREF_ENTRY_VALUES = arrayOf("1200w", "800w", "600w_50q")
private val IMAGE_QUALITY_PREF_DEFAULT_VALUE = IMAGE_QUALITY_PREF_ENTRY_VALUES[0]
private const val IMAGE_FORMAT_PREF_KEY = "chapterImageFormat"
private val IMAGE_FORMAT_PREF_ENTRIES = arrayOf("JPG", "WEBP", "PNG")

View File

@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.source.SourceFactory
class BilibiliFactory : SourceFactory {
override fun createSources(): List<Source> = listOf(
BilibiliComics(),
BilibiliManhua()
BilibiliManga()
)
}
@ -32,7 +32,7 @@ class BilibiliComics : Bilibili("BILIBILI COMICS", "https://www.bilibilicomics.c
)
}
class BilibiliManhua : Bilibili("哔哩哔哩漫画", "https://manga.bilibili.com", "zh") {
class BilibiliManga : Bilibili("哔哩哔哩漫画", "https://manga.bilibili.com", "zh") {
override val statusLabel: String = "进度"
@ -50,15 +50,14 @@ class BilibiliManhua : Bilibili("哔哩哔哩漫画", "https://manga.bilibili.co
override val defaultLatestSort: Int = 1
// Machine translated, needs to be revisited.
override val hasPaidChaptersWarning: String = "本系列已付费章节从章节列表中过滤掉。 " +
"暂时使用哔哩哔哩网站或官方应用程序阅读它们。"
override val hasPaidChaptersWarning: String = "此漫画的付费章节已从章节列表中过滤," +
"暂时请用网页端或官方app阅读。"
// Machine translated, needs to be revisited.
override val resolutionPrefTitle: String = "章节图像分辨率"
override val imageQualityPrefTitle: String = "章节图片质量"
// Machine translated, needs to be revisited.
override val imagePrefTitle: String = "章节图像格式"
override val imageQualityPrefEntries: Array<String> = arrayOf("原图", "", "")
override val imageFormatPrefTitle: String = "章节图片格式"
override fun getAllStatus(): Array<String> = arrayOf("全部", "连载", "完结")