Extract more strings to localizable files

This commit is contained in:
Jobobby04
2021-12-12 20:40:11 -05:00
parent 0936d4b844
commit f2250e7cee
7 changed files with 76 additions and 44 deletions
@@ -112,7 +112,8 @@ class EditMangaDialog : DialogController {
if (manga.title != manga.url) {
binding.title.setText(manga.title)
}
binding.title.hint = "${resources?.getString(R.string.title)}: ${manga.url}"
binding.title.hint = context.getString(R.string.title_hint, manga.url)
binding.mangaAuthor.setText(manga.author.orEmpty())
binding.mangaArtist.setText(manga.artist.orEmpty())
binding.mangaDescription.setText(manga.description.orEmpty())
@@ -132,19 +133,22 @@ class EditMangaDialog : DialogController {
}
binding.mangaGenresTags.setChips(manga.getGenres().orEmpty().dropBlank())
binding.title.hint = "${resources?.getString(R.string.title)}: ${manga.originalTitle}"
binding.title.hint = context.getString(R.string.title_hint, manga.originalTitle)
if (manga.originalAuthor != null) {
binding.mangaAuthor.hint = "Author: ${manga.originalAuthor}"
binding.mangaAuthor.hint = context.getString(R.string.author_hint, manga.originalAuthor)
}
if (manga.originalArtist != null) {
binding.mangaArtist.hint = "Artist: ${manga.originalArtist}"
binding.mangaArtist.hint = context.getString(R.string.artist_hint, manga.originalArtist)
}
if (manga.originalDescription != null) {
binding.mangaDescription.hint =
"${resources?.getString(R.string.description)}: ${manga.originalDescription?.replace(
"\n",
" "
)?.chop(20)}"
context.getString(
R.string.description_hint,
manga.originalDescription?.replace(
"\n",
" "
)?.chop(20)
)
}
}
binding.mangaGenresTags.clearFocus()
@@ -110,7 +110,6 @@ import exh.source.isMdBasedSource
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.withContext
@@ -737,7 +736,7 @@ class MangaController :
suspend fun mergeWithAnother() {
try {
val mergedManga = withContext(Dispatchers.IO + NonCancellable) {
presenter.smartSearchMerge(presenter.manga, smartSearchConfig?.origMangaId!!)
presenter.smartSearchMerge(applicationContext!!, presenter.manga, smartSearchConfig?.origMangaId!!)
}
router?.popControllerWithTag(SMART_SEARCH_SOURCE_TAG)
@@ -749,12 +748,12 @@ class MangaController :
update = true
).withFadeTransaction()
)
applicationContext?.toast("Manga merged!")
applicationContext?.toast(R.string.manga_merged)
} catch (e: Exception) {
if (e is CancellationException) throw e
else {
applicationContext?.toast("Failed to merge manga: ${e.message}")
}
val activity = activity ?: return
activity.toast(activity.getString(R.string.failed_merge, e.message))
}
}
// EXH <--
@@ -8,6 +8,7 @@ import android.os.Bundle
import coil.imageLoader
import coil.memory.MemoryCache
import com.jakewharton.rxrelay.PublishRelay
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category
@@ -400,12 +401,13 @@ class MangaPresenter(
}
}
suspend fun smartSearchMerge(manga: Manga, originalMangaId: Long): Manga {
val originalManga = db.getManga(originalMangaId).executeAsBlocking() ?: throw IllegalArgumentException("Unknown manga ID: $originalMangaId")
suspend fun smartSearchMerge(context: Context, manga: Manga, originalMangaId: Long): Manga {
val originalManga = db.getManga(originalMangaId).executeAsBlocking()
?: throw IllegalArgumentException(context.getString(R.string.merge_unknown_manga, originalMangaId))
if (originalManga.source == MERGED_SOURCE_ID) {
val children = db.getMergedMangaReferences(originalMangaId).executeAsBlocking()
if (children.any { it.mangaSourceId == manga.source && it.mangaUrl == manga.url }) {
throw IllegalArgumentException("This manga is already merged with the current manga!")
throw IllegalArgumentException(context.getString(R.string.merged_already))
}
val mangaReferences = mutableListOf(
@@ -456,7 +458,7 @@ class MangaPresenter(
var existingManga = db.getManga(mergedManga.url, mergedManga.source).executeAsBlocking()
while (existingManga != null) {
if (existingManga.favorite) {
throw IllegalArgumentException("This merged manga is a duplicate!")
throw IllegalArgumentException(context.getString(R.string.merge_duplicate))
} else if (!existingManga.favorite) {
withContext(NonCancellable) {
db.deleteManga(existingManga!!).executeAsBlocking()
@@ -6,6 +6,7 @@ import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EditMergedSettingsHeaderBinding
import eu.kanade.tachiyomi.source.SourceManager
import exh.log.xLogD
@@ -40,11 +41,11 @@ class EditMergedSettingsHeaderAdapter(private val controller: EditMergedSettings
val dedupeAdapter: ArrayAdapter<String> = ArrayAdapter(
itemView.context,
android.R.layout.simple_spinner_item,
listOf(
"No dedupe",
/*"Dedupe by priority",*/
"Show source with most chapters",
"Show source with highest chapter number"
listOfNotNull(
itemView.context.getString(R.string.no_dedupe),
itemView.context.getString(R.string.dedupe_priority).let { null },
itemView.context.getString(R.string.dedupe_most_chapters),
itemView.context.getString(R.string.dedupe_highest_chapter)
)
)
dedupeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
@@ -780,7 +780,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
retried++
}
toast("Retrying $retried failed pages...")
toast(resources.getQuantityString(R.plurals.eh_retry_toast, retried, retried))
}
.launchIn(lifecycleScope)
@@ -796,26 +796,25 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
binding.ehBoostPage.clicks()
.onEach {
viewer?.let { _ ->
val curPage = exhCurrentpage() ?: run {
toast("This page cannot be boosted (invalid page)!")
return@let
}
viewer ?: return@onEach
val curPage = exhCurrentpage() ?: run {
toast(R.string.eh_boost_page_invalid)
return@onEach
}
if (curPage.status == Page.ERROR) {
toast("Page failed to load, press the retry button instead!")
} else if (curPage.status == Page.LOAD_PAGE || curPage.status == Page.DOWNLOAD_IMAGE) {
toast("This page is already downloading!")
} else if (curPage.status == Page.READY) {
toast("This page has already been downloaded!")
if (curPage.status == Page.ERROR) {
toast(R.string.eh_boost_page_errored)
} else if (curPage.status == Page.LOAD_PAGE || curPage.status == Page.DOWNLOAD_IMAGE) {
toast(R.string.eh_boost_page_downloading)
} else if (curPage.status == Page.READY) {
toast(R.string.eh_boost_page_downloaded)
} else {
val loader = (presenter.viewerChaptersRelay.value.currChapter.pageLoader as? HttpPageLoader)
if (loader != null) {
loader.boostPage(curPage)
toast(R.string.eh_boost_boosted)
} else {
val loader = (presenter.viewerChaptersRelay.value.currChapter.pageLoader as? HttpPageLoader)
if (loader != null) {
loader.boostPage(curPage)
toast("Boosted current page!")
} else {
toast("This page cannot be boosted (invalid page loader)!")
}
toast(R.string.eh_boost_invalid_loader)
}
}
}
@@ -3,6 +3,7 @@ package exh.ui.smartsearch
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EhSmartSearchBinding
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.SourceManager
@@ -47,9 +48,9 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartS
router.replaceTopController(transaction)
} else {
if (results is SmartSearchPresenter.SearchResults.NotFound) {
applicationContext?.toast("Couldn't find the manga in the source!")
applicationContext?.toast(R.string.could_not_find_manga)
} else {
applicationContext?.toast("Error performing automatic search!")
applicationContext?.toast(R.string.automatic_search_error)
}
val transaction = BrowseSourceController(
source,