Skip to content

Commit

Permalink
Implement i18nTail for improved string handling (#190)
Browse files Browse the repository at this point in the history
* Implement i18nTail for improved string handling

* formatt

* Translations update from Crowdin
  • Loading branch information
Dark25 authored Jan 13, 2025
1 parent f5aca86 commit 986869f
Show file tree
Hide file tree
Showing 77 changed files with 4,422 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
- '!i18n/src/commonMain/moko-resources/**/strings.xml'
- '!i18n/src/commonMain/moko-resources/**/plurals-aniyomi.xml'
- '!i18n/src/commonMain/moko-resources/**/plurals.xml'
- 'i18n/src/main/res/**/strings-animetail.xml'
- 'i18n-tail/src/commonMain/moko-resources/base/strings.xml'
- 'i18n-tail/src/commonMain/moko-resources/base/plurals.xml'
- 'i18n/src/commonMain/moko-resources/base/strings-aniyomi.xml'
- 'i18n/src/commonMain/moko-resources/base/strings.xml'
- 'i18n/src/commonMain/moko-resources/base/plurals-aniyomi.xml'
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("com.github.zellius.shortcut-helper")
kotlin("plugin.serialization")
alias(libs.plugins.aboutLibraries)
id("com.github.ben-manes.versions")
}

if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
Expand Down Expand Up @@ -147,6 +148,9 @@ android {

dependencies {
implementation(projects.i18n)
// TAIL
implementation(projects.i18nTail)
// TAIL
implementation(projects.core.archive)
implementation(projects.core.common)
implementation(projects.coreMetadata)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/eu/kanade/domain/ui/model/AppTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package eu.kanade.domain.ui.model

import dev.icerock.moko.resources.StringResource
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR

enum class AppTheme(val titleRes: StringResource?) {
DEFAULT(MR.strings.label_default),
MONET(MR.strings.theme_monet),
CUSTOM(MR.strings.theme_custom),
CUSTOM(TLMR.strings.theme_custom),
CLOUDFLARE(MR.strings.theme_cloudflare),
COTTONCANDY(MR.strings.theme_cottoncandy),
DOOM(MR.strings.theme_doom),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import tachiyomi.domain.items.episode.interactor.GetEpisode
import tachiyomi.domain.items.episode.model.Episode
import tachiyomi.domain.source.anime.service.AnimeSourceManager
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.components.material.padding
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.screens.LoadingScreen
Expand Down Expand Up @@ -383,7 +384,7 @@ private fun QualityOptions(

)
ClickableRow(
text = stringResource(MR.strings.action_cast), // Texto para la nueva opción
text = stringResource(TLMR.strings.action_cast), // Texto para la nueva opción
icon = Icons.Outlined.Cast, // Icono para la nueva opción
onClick = {
onCastClicked()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import androidx.compose.material.icons.outlined.BookmarkRemove
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.DoneAll
import androidx.compose.material.icons.outlined.Download
import androidx.compose.material.icons.outlined.Input
import androidx.compose.material.icons.outlined.OpenInNew
import androidx.compose.material.icons.outlined.RemoveDone
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -62,6 +60,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.i18n.stringResource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
Expand Down Expand Up @@ -363,7 +362,7 @@ fun LibraryBottomActionMenu(
// SY -->
if (showOverflow) {
Button(
title = stringResource(MR.strings.reset_info),
title = stringResource(TLMR.strings.reset_info),
icon = Icons.Outlined.Delete,
toConfirm = confirm[5],
onLongClick = { onLongClickItem(5) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import eu.kanade.presentation.components.UpIcon
import eu.kanade.presentation.entries.DownloadAction
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.theme.active

Expand Down Expand Up @@ -130,7 +131,7 @@ fun EntryToolbar(
if (onClickEditInfo != null) {
add(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_edit_info),
title = stringResource(TLMR.strings.action_edit_info),
onClick = onClickEditInfo,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import tachiyomi.domain.library.anime.model.sort
import tachiyomi.domain.library.model.LibraryDisplayMode
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.components.BaseSortItem
import tachiyomi.presentation.core.components.CheckboxItem
import tachiyomi.presentation.core.components.HeadingItem
Expand Down Expand Up @@ -62,7 +63,7 @@ fun AnimeLibrarySettingsDialog(
stringResource(MR.strings.action_sort),
stringResource(MR.strings.action_display),
// SY -->
stringResource(MR.strings.group),
stringResource(TLMR.strings.group),
// SY <--
),
) { page ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.components.SearchToolbar
import kotlinx.collections.immutable.persistentListOf
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.components.Pill
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.theme.active
Expand Down Expand Up @@ -122,7 +123,7 @@ private fun LibraryRegularToolbar(
onClick = onClickOpenRandomEntry,
),
AppBar.OverflowAction(
title = stringResource(MR.strings.sync_library),
title = stringResource(TLMR.strings.sync_library),
onClick = onClickSyncNow,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import tachiyomi.domain.library.manga.model.sort
import tachiyomi.domain.library.model.LibraryDisplayMode
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.components.BaseSortItem
import tachiyomi.presentation.core.components.CheckboxItem
import tachiyomi.presentation.core.components.HeadingItem
Expand Down Expand Up @@ -62,7 +63,7 @@ fun MangaLibrarySettingsDialog(
stringResource(MR.strings.action_sort),
stringResource(MR.strings.action_display),
// SY -->
stringResource(MR.strings.group),
stringResource(TLMR.strings.group),
// SY <--
),
) { page ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import eu.kanade.presentation.more.settings.widget.AppThemePreferenceWidget
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableMap
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.collectAsState
import uy.kohesive.injekt.Injekt
Expand Down Expand Up @@ -72,8 +72,8 @@ object SettingsAppearanceScreen : SearchableSettings {
val customPreferenceItem = if (appTheme == AppTheme.CUSTOM) {
listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_custom_color),
subtitle = stringResource(MR.strings.custom_color_description),
title = stringResource(TLMR.strings.pref_custom_color),
subtitle = stringResource(TLMR.strings.custom_color_description),
onClick = { navigator.push(AppCustomThemeColorPickerScreen()) },
),
)
Expand Down Expand Up @@ -194,19 +194,19 @@ object SettingsAppearanceScreen : SearchableSettings {
@Composable
fun getNavbarGroup(uiPreferences: UiPreferences): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
stringResource(MR.strings.pref_category_navbar),
stringResource(TLMR.strings.pref_category_navbar),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
pref = uiPreferences.showNavUpdates(),
title = stringResource(MR.strings.pref_hide_updates_button),
title = stringResource(TLMR.strings.pref_hide_updates_button),
),
Preference.PreferenceItem.SwitchPreference(
pref = uiPreferences.showNavHistory(),
title = stringResource(MR.strings.pref_hide_history_button),
title = stringResource(TLMR.strings.pref_hide_history_button),
),
Preference.PreferenceItem.SwitchPreference(
pref = uiPreferences.bottomBarLabels(),
title = stringResource(MR.strings.pref_show_bottom_bar_labels),
title = stringResource(TLMR.strings.pref_show_bottom_bar_labels),
),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import kotlinx.collections.immutable.persistentListOf
import tachiyomi.core.common.util.lang.launchIO
import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get

Expand All @@ -59,7 +60,7 @@ object SettingsConnectionsScreen : SearchableSettings {
@ReadOnlyComposable
@Composable
@StringRes
override fun getTitleRes() = MR.strings.pref_category_connections
override fun getTitleRes() = TLMR.strings.pref_category_connections

@Composable
override fun getPreferences(): List<Preference> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import tachiyomi.domain.backup.service.BackupPreferences
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.domain.storage.service.StoragePreferences
import tachiyomi.i18n.MR
import tachiyomi.i18n.tail.TLMR
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.collectAsState
import uy.kohesive.injekt.Injekt
Expand Down Expand Up @@ -325,7 +326,7 @@ object SettingsDataScreen : SearchableSettings {
// AM (FILE_SIZE) -->
Preference.PreferenceItem.SwitchPreference(
pref = storagePreferences.showEpisodeFileSize(),
title = stringResource(MR.strings.pref_show_downloaded_episode_file_size),
title = stringResource(TLMR.strings.pref_show_downloaded_episode_file_size),
),
// <-- AM (FILE_SIZE)

Expand Down Expand Up @@ -367,15 +368,15 @@ object SettingsDataScreen : SearchableSettings {
private fun getSyncPreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> {
return listOf(
Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_sync_service_category),
title = stringResource(TLMR.strings.pref_sync_service_category),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
pref = syncPreferences.syncService(),
title = stringResource(MR.strings.pref_sync_service),
title = stringResource(TLMR.strings.pref_sync_service),
entries = persistentMapOf(
SyncManager.SyncService.NONE.value to stringResource(MR.strings.off),
SyncManager.SyncService.SYNCYOMI.value to stringResource(MR.strings.syncyomi),
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(MR.strings.google_drive),
SyncManager.SyncService.SYNCYOMI.value to stringResource(TLMR.strings.syncyomi),
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(TLMR.strings.google_drive),
),
onValueChanged = { true },
),
Expand Down Expand Up @@ -420,7 +421,7 @@ object SettingsDataScreen : SearchableSettings {
val googleDriveSync = Injekt.get<GoogleDriveService>()
return listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_google_drive_sign_in),
title = stringResource(TLMR.strings.pref_google_drive_sign_in),
onClick = {
val intent = googleDriveSync.getSignInIntent()
context.startActivity(intent)
Expand All @@ -445,19 +446,19 @@ object SettingsDataScreen : SearchableSettings {
val result = googleDriveSync.deleteSyncDataFromGoogleDrive()
when (result) {
GoogleDriveSyncService.DeleteSyncDataStatus.NOT_INITIALIZED -> context.toast(
MR.strings.google_drive_not_signed_in,
TLMR.strings.google_drive_not_signed_in,
duration = 5000,
)
GoogleDriveSyncService.DeleteSyncDataStatus.NO_FILES -> context.toast(
MR.strings.google_drive_sync_data_not_found,
TLMR.strings.google_drive_sync_data_not_found,
duration = 5000,
)
GoogleDriveSyncService.DeleteSyncDataStatus.SUCCESS -> context.toast(
MR.strings.google_drive_sync_data_purged,
TLMR.strings.google_drive_sync_data_purged,
duration = 5000,
)
GoogleDriveSyncService.DeleteSyncDataStatus.ERROR -> context.toast(
MR.strings.google_drive_sync_data_purge_error,
TLMR.strings.google_drive_sync_data_purge_error,
duration = 10000,
)
}
Expand All @@ -468,7 +469,7 @@ object SettingsDataScreen : SearchableSettings {
}

return Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_google_drive_purge_sync_data),
title = stringResource(TLMR.strings.pref_google_drive_purge_sync_data),
onClick = { showPurgeDialog = true },
)
}
Expand All @@ -480,8 +481,8 @@ object SettingsDataScreen : SearchableSettings {
) {
AlertDialog(
onDismissRequest = onDismissRequest,
title = { Text(text = stringResource(MR.strings.pref_purge_confirmation_title)) },
text = { Text(text = stringResource(MR.strings.pref_purge_confirmation_message)) },
title = { Text(text = stringResource(TLMR.strings.pref_purge_confirmation_title)) },
text = { Text(text = stringResource(TLMR.strings.pref_purge_confirmation_message)) },
dismissButton = {
TextButton(onClick = onDismissRequest) {
Text(text = stringResource(MR.strings.action_cancel))
Expand All @@ -500,8 +501,8 @@ object SettingsDataScreen : SearchableSettings {
val scope = rememberCoroutineScope()
return listOf(
Preference.PreferenceItem.EditTextPreference(
title = stringResource(MR.strings.pref_sync_host),
subtitle = stringResource(MR.strings.pref_sync_host_summ),
title = stringResource(TLMR.strings.pref_sync_host),
subtitle = stringResource(TLMR.strings.pref_sync_host_summ),
pref = syncPreferences.clientHost(),
onValueChanged = { newValue ->
scope.launch {
Expand All @@ -514,8 +515,8 @@ object SettingsDataScreen : SearchableSettings {
},
),
Preference.PreferenceItem.EditTextPreference(
title = stringResource(MR.strings.pref_sync_api_key),
subtitle = stringResource(MR.strings.pref_sync_api_key_summ),
title = stringResource(TLMR.strings.pref_sync_api_key),
subtitle = stringResource(TLMR.strings.pref_sync_api_key_summ),
pref = syncPreferences.clientAPIKey(),
),
)
Expand All @@ -525,12 +526,12 @@ object SettingsDataScreen : SearchableSettings {
private fun getSyncNowPref(): Preference.PreferenceGroup {
val navigator = LocalNavigator.currentOrThrow
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_sync_now_group_title),
title = stringResource(TLMR.strings.pref_sync_now_group_title),
preferenceItems = persistentListOf(
getSyncOptionsPref(),
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_sync_now),
subtitle = stringResource(MR.strings.pref_sync_now_subtitle),
title = stringResource(TLMR.strings.pref_sync_now),
subtitle = stringResource(TLMR.strings.pref_sync_now_subtitle),
onClick = {
navigator.push(SyncSettingsSelector())
},
Expand All @@ -543,8 +544,8 @@ object SettingsDataScreen : SearchableSettings {
private fun getSyncOptionsPref(): Preference.PreferenceItem.TextPreference {
val navigator = LocalNavigator.currentOrThrow
return Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_sync_options),
subtitle = stringResource(MR.strings.pref_sync_options_summ),
title = stringResource(TLMR.strings.pref_sync_options),
subtitle = stringResource(TLMR.strings.pref_sync_options_summ),
onClick = { navigator.push(SyncTriggerOptionsScreen()) },
)
}
Expand All @@ -557,16 +558,16 @@ object SettingsDataScreen : SearchableSettings {
val lastSync by syncPreferences.lastSyncTimestamp().collectAsState()

return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_sync_automatic_category),
title = stringResource(TLMR.strings.pref_sync_automatic_category),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
pref = syncIntervalPref,
title = stringResource(MR.strings.pref_sync_interval),
title = stringResource(TLMR.strings.pref_sync_interval),
entries = persistentMapOf(
0 to stringResource(MR.strings.off),
30 to stringResource(MR.strings.update_30min),
60 to stringResource(MR.strings.update_1hour),
180 to stringResource(MR.strings.update_3hour),
30 to stringResource(TLMR.strings.update_30min),
60 to stringResource(TLMR.strings.update_1hour),
180 to stringResource(TLMR.strings.update_3hour),
360 to stringResource(MR.strings.update_6hour),
720 to stringResource(MR.strings.update_12hour),
1440 to stringResource(MR.strings.update_24hour),
Expand All @@ -579,7 +580,7 @@ object SettingsDataScreen : SearchableSettings {
},
),
Preference.PreferenceItem.InfoPreference(
stringResource(MR.strings.last_synchronization, relativeTimeSpanString(lastSync)),
stringResource(TLMR.strings.last_synchronization, relativeTimeSpanString(lastSync)),
),
),
)
Expand Down
Loading

0 comments on commit 986869f

Please sign in to comment.