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

View File

@ -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()

View File

@ -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 <--

View File

@ -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()

View File

@ -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)

View File

@ -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)
}
}
}

View File

@ -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,

View File

@ -277,8 +277,19 @@
<string name="eh_autoscroll_help_message">Automatically scroll to the next page in the specified interval. Interval is specified in seconds.</string>
<string name="eh_retry_all_help">Retry all help</string>
<string name="eh_retry_all_help_message">Re-add all failed pages to the download queue.</string>
<plurals name="eh_retry_toast">
<item quantity="zero">Retrying 0 failed pages…</item>
<item quantity="one">Retrying %1$d failed page…</item>
<item quantity="other">Retrying %1$d failed pages…</item>
</plurals>
<string name="eh_boost_page_help">Boost page help</string>
<string name="eh_boost_page_help_message">Normally the downloader can only download a specific amount of pages at the same time. This means you can be waiting for a page to download but the downloader will not start downloading the page until it has a free download slot. Pressing \'Boost page\' will force the downloader to begin downloading the current page, regardless of whether or not there is an available slot.</string>
<string name="eh_boost_page_invalid">This page cannot be boosted (invalid page)!</string>
<string name="eh_boost_page_errored">Page failed to load, press the retry button instead!</string>
<string name="eh_boost_page_downloading">This page is already downloading!</string>
<string name="eh_boost_page_downloaded">This page has already been downloaded!</string>
<string name="eh_boost_boosted">Boosted current page!</string>
<string name="eh_boost_invalid_loader">This page cannot be boosted (invalid page loader)!</string>
<string name="pref_crop_borders_pager">Crop borders Pager</string>
<string name="pref_crop_borders_continuous_vertical">Crop borders Continuous Vertical</string>
<string name="pref_crop_borders_webtoon">Crop borders Webtoon</string>
@ -311,6 +322,11 @@
<string name="az_recommends">See Recommendations</string>
<string name="merge">Merge</string>
<string name="merge_with_another_source">Merge With Another</string>
<string name="manga_merged">Manga merged!</string>
<string name="failed_merge">Failed to merge manga: %1$s</string>
<string name="merge_unknown_manga">Unknown manga ID: %1$d</string>
<string name="merged_already">This manga is already merged with the current manga!</string>
<string name="merge_duplicate">This merged manga is a duplicate!</string>
<!-- Manga info fragment -->
<string name="hiatus">Hiatus</string>
@ -320,6 +336,10 @@
<!-- Manga Info Edit -->
<string name="reset_tags">Reset Tags</string>
<string name="add_tag">Add Tag</string>
<string name="title_hint">Title: %1$s</string>
<string name="description_hint">Description: %1$s</string>
<string name="author_hint">Author: %1$s</string>
<string name="artist_hint">Artist: %1$s</string>
<!-- Browse -->
<!-- Sources Tab -->
@ -329,6 +349,8 @@
<!-- Smart Search -->
<string name="searching_source">Searching source…</string>
<string name="could_not_find_manga">Couldn\'t find the manga in the source!</string>
<string name="automatic_search_error">Error performing automatic search!</string>
<!-- Saved Searches -->
<string name="saved_searches">Saved Searches</string>
@ -619,6 +641,10 @@
<string name="manga_info_manga">Info manga:</string>
<string name="toggle_dedupe">Toggle dedupe</string>
<string name="refresh_merge">Refresh to get proper info</string>
<string name="no_dedupe">No dedupe</string>
<string name="dedupe_priority">Dedupe by priority</string>
<string name="dedupe_most_chapters">Show source with most chapters</string>
<string name="dedupe_highest_chapter">Show source with highest chapter number</string>
<!-- MangaDex -->
<string name="mdlist">MDList</string>