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) { if (manga.title != manga.url) {
binding.title.setText(manga.title) 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.mangaAuthor.setText(manga.author.orEmpty())
binding.mangaArtist.setText(manga.artist.orEmpty()) binding.mangaArtist.setText(manga.artist.orEmpty())
binding.mangaDescription.setText(manga.description.orEmpty()) binding.mangaDescription.setText(manga.description.orEmpty())
@ -132,19 +133,22 @@ class EditMangaDialog : DialogController {
} }
binding.mangaGenresTags.setChips(manga.getGenres().orEmpty().dropBlank()) 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) { 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) { 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) { if (manga.originalDescription != null) {
binding.mangaDescription.hint = binding.mangaDescription.hint =
"${resources?.getString(R.string.description)}: ${manga.originalDescription?.replace( context.getString(
"\n", R.string.description_hint,
" " manga.originalDescription?.replace(
)?.chop(20)}" "\n",
" "
)?.chop(20)
)
} }
} }
binding.mangaGenresTags.clearFocus() binding.mangaGenresTags.clearFocus()

View File

@ -110,7 +110,6 @@ import exh.source.isMdBasedSource
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -737,7 +736,7 @@ class MangaController :
suspend fun mergeWithAnother() { suspend fun mergeWithAnother() {
try { try {
val mergedManga = withContext(Dispatchers.IO + NonCancellable) { 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) router?.popControllerWithTag(SMART_SEARCH_SOURCE_TAG)
@ -749,12 +748,12 @@ class MangaController :
update = true update = true
).withFadeTransaction() ).withFadeTransaction()
) )
applicationContext?.toast("Manga merged!") applicationContext?.toast(R.string.manga_merged)
} catch (e: Exception) { } catch (e: Exception) {
if (e is CancellationException) throw e 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 <-- // EXH <--

View File

@ -8,6 +8,7 @@ import android.os.Bundle
import coil.imageLoader import coil.imageLoader
import coil.memory.MemoryCache import coil.memory.MemoryCache
import com.jakewharton.rxrelay.PublishRelay import com.jakewharton.rxrelay.PublishRelay
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.data.database.models.Category
@ -400,12 +401,13 @@ class MangaPresenter(
} }
} }
suspend fun smartSearchMerge(manga: Manga, originalMangaId: Long): Manga { suspend fun smartSearchMerge(context: Context, manga: Manga, originalMangaId: Long): Manga {
val originalManga = db.getManga(originalMangaId).executeAsBlocking() ?: throw IllegalArgumentException("Unknown manga ID: $originalMangaId") val originalManga = db.getManga(originalMangaId).executeAsBlocking()
?: throw IllegalArgumentException(context.getString(R.string.merge_unknown_manga, originalMangaId))
if (originalManga.source == MERGED_SOURCE_ID) { if (originalManga.source == MERGED_SOURCE_ID) {
val children = db.getMergedMangaReferences(originalMangaId).executeAsBlocking() val children = db.getMergedMangaReferences(originalMangaId).executeAsBlocking()
if (children.any { it.mangaSourceId == manga.source && it.mangaUrl == manga.url }) { 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( val mangaReferences = mutableListOf(
@ -456,7 +458,7 @@ class MangaPresenter(
var existingManga = db.getManga(mergedManga.url, mergedManga.source).executeAsBlocking() var existingManga = db.getManga(mergedManga.url, mergedManga.source).executeAsBlocking()
while (existingManga != null) { while (existingManga != null) {
if (existingManga.favorite) { if (existingManga.favorite) {
throw IllegalArgumentException("This merged manga is a duplicate!") throw IllegalArgumentException(context.getString(R.string.merge_duplicate))
} else if (!existingManga.favorite) { } else if (!existingManga.favorite) {
withContext(NonCancellable) { withContext(NonCancellable) {
db.deleteManga(existingManga!!).executeAsBlocking() db.deleteManga(existingManga!!).executeAsBlocking()

View File

@ -6,6 +6,7 @@ import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EditMergedSettingsHeaderBinding import eu.kanade.tachiyomi.databinding.EditMergedSettingsHeaderBinding
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
import exh.log.xLogD import exh.log.xLogD
@ -40,11 +41,11 @@ class EditMergedSettingsHeaderAdapter(private val controller: EditMergedSettings
val dedupeAdapter: ArrayAdapter<String> = ArrayAdapter( val dedupeAdapter: ArrayAdapter<String> = ArrayAdapter(
itemView.context, itemView.context,
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_item,
listOf( listOfNotNull(
"No dedupe", itemView.context.getString(R.string.no_dedupe),
/*"Dedupe by priority",*/ itemView.context.getString(R.string.dedupe_priority).let { null },
"Show source with most chapters", itemView.context.getString(R.string.dedupe_most_chapters),
"Show source with highest chapter number" itemView.context.getString(R.string.dedupe_highest_chapter)
) )
) )
dedupeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) dedupeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)

View File

@ -780,7 +780,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
retried++ retried++
} }
toast("Retrying $retried failed pages...") toast(resources.getQuantityString(R.plurals.eh_retry_toast, retried, retried))
} }
.launchIn(lifecycleScope) .launchIn(lifecycleScope)
@ -796,26 +796,25 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
binding.ehBoostPage.clicks() binding.ehBoostPage.clicks()
.onEach { .onEach {
viewer?.let { _ -> viewer ?: return@onEach
val curPage = exhCurrentpage() ?: run { val curPage = exhCurrentpage() ?: run {
toast("This page cannot be boosted (invalid page)!") toast(R.string.eh_boost_page_invalid)
return@let return@onEach
} }
if (curPage.status == Page.ERROR) { if (curPage.status == Page.ERROR) {
toast("Page failed to load, press the retry button instead!") toast(R.string.eh_boost_page_errored)
} else if (curPage.status == Page.LOAD_PAGE || curPage.status == Page.DOWNLOAD_IMAGE) { } else if (curPage.status == Page.LOAD_PAGE || curPage.status == Page.DOWNLOAD_IMAGE) {
toast("This page is already downloading!") toast(R.string.eh_boost_page_downloading)
} else if (curPage.status == Page.READY) { } else if (curPage.status == Page.READY) {
toast("This page has already been downloaded!") 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 { } else {
val loader = (presenter.viewerChaptersRelay.value.currChapter.pageLoader as? HttpPageLoader) toast(R.string.eh_boost_invalid_loader)
if (loader != null) {
loader.boostPage(curPage)
toast("Boosted current page!")
} else {
toast("This page cannot be boosted (invalid page loader)!")
}
} }
} }
} }

View File

@ -3,6 +3,7 @@ package exh.ui.smartsearch
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.EhSmartSearchBinding import eu.kanade.tachiyomi.databinding.EhSmartSearchBinding
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.SourceManager
@ -47,9 +48,9 @@ class SmartSearchController(bundle: Bundle? = null) : NucleusController<EhSmartS
router.replaceTopController(transaction) router.replaceTopController(transaction)
} else { } else {
if (results is SmartSearchPresenter.SearchResults.NotFound) { 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 { } else {
applicationContext?.toast("Error performing automatic search!") applicationContext?.toast(R.string.automatic_search_error)
} }
val transaction = BrowseSourceController( val transaction = BrowseSourceController(
source, 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_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">Retry all help</string>
<string name="eh_retry_all_help_message">Re-add all failed pages to the download queue.</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">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_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_pager">Crop borders Pager</string>
<string name="pref_crop_borders_continuous_vertical">Crop borders Continuous Vertical</string> <string name="pref_crop_borders_continuous_vertical">Crop borders Continuous Vertical</string>
<string name="pref_crop_borders_webtoon">Crop borders Webtoon</string> <string name="pref_crop_borders_webtoon">Crop borders Webtoon</string>
@ -311,6 +322,11 @@
<string name="az_recommends">See Recommendations</string> <string name="az_recommends">See Recommendations</string>
<string name="merge">Merge</string> <string name="merge">Merge</string>
<string name="merge_with_another_source">Merge With Another</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 --> <!-- Manga info fragment -->
<string name="hiatus">Hiatus</string> <string name="hiatus">Hiatus</string>
@ -320,6 +336,10 @@
<!-- Manga Info Edit --> <!-- Manga Info Edit -->
<string name="reset_tags">Reset Tags</string> <string name="reset_tags">Reset Tags</string>
<string name="add_tag">Add Tag</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 --> <!-- Browse -->
<!-- Sources Tab --> <!-- Sources Tab -->
@ -329,6 +349,8 @@
<!-- Smart Search --> <!-- Smart Search -->
<string name="searching_source">Searching source…</string> <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 --> <!-- Saved Searches -->
<string name="saved_searches">Saved Searches</string> <string name="saved_searches">Saved Searches</string>
@ -619,6 +641,10 @@
<string name="manga_info_manga">Info manga:</string> <string name="manga_info_manga">Info manga:</string>
<string name="toggle_dedupe">Toggle dedupe</string> <string name="toggle_dedupe">Toggle dedupe</string>
<string name="refresh_merge">Refresh to get proper info</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 --> <!-- MangaDex -->
<string name="mdlist">MDList</string> <string name="mdlist">MDList</string>