mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-09 18:48:55 +01:00
Migrate to multiplatform string resources (#10147)
* Migrate to multiplatform string resources * Move plurals translations into separate files * Fix lint check on generated files
This commit is contained in:
@@ -9,10 +9,11 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.tachiyomi.R
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import tachiyomi.core.preference.CheckboxState
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.LabeledCheckbox
|
||||
import tachiyomi.presentation.core.i18n.localize
|
||||
|
||||
@Composable
|
||||
fun DeleteLibraryMangaDialog(
|
||||
@@ -22,10 +23,10 @@ fun DeleteLibraryMangaDialog(
|
||||
) {
|
||||
var list by remember {
|
||||
mutableStateOf(
|
||||
buildList<CheckboxState.State<Int>> {
|
||||
add(CheckboxState.State.None(R.string.manga_from_library))
|
||||
buildList<CheckboxState.State<StringResource>> {
|
||||
add(CheckboxState.State.None(MR.strings.manga_from_library))
|
||||
if (!containsLocalManga) {
|
||||
add(CheckboxState.State.None(R.string.downloaded_chapters))
|
||||
add(CheckboxState.State.None(MR.strings.downloaded_chapters))
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -34,7 +35,7 @@ fun DeleteLibraryMangaDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismissRequest) {
|
||||
Text(text = stringResource(R.string.action_cancel))
|
||||
Text(text = localize(MR.strings.action_cancel))
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
@@ -48,23 +49,23 @@ fun DeleteLibraryMangaDialog(
|
||||
)
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(R.string.action_ok))
|
||||
Text(text = localize(MR.strings.action_ok))
|
||||
}
|
||||
},
|
||||
title = {
|
||||
Text(text = stringResource(R.string.action_remove))
|
||||
Text(text = localize(MR.strings.action_remove))
|
||||
},
|
||||
text = {
|
||||
Column {
|
||||
list.forEach { state ->
|
||||
LabeledCheckbox(
|
||||
label = stringResource(state.value),
|
||||
label = localize(state.value),
|
||||
checked = state.isChecked,
|
||||
onCheckedChange = {
|
||||
val index = list.indexOf(state)
|
||||
if (index != -1) {
|
||||
val mutableList = list.toMutableList()
|
||||
mutableList[index] = state.next() as CheckboxState.State<Int>
|
||||
mutableList[index] = state.next() as CheckboxState.State<StringResource>
|
||||
list = mutableList.toList()
|
||||
}
|
||||
},
|
||||
|
||||
@@ -13,10 +13,8 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import eu.kanade.presentation.components.TabbedDialog
|
||||
import eu.kanade.presentation.components.TabbedDialogPaddings
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.library.LibrarySettingsScreenModel
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import tachiyomi.core.preference.TriState
|
||||
@@ -25,12 +23,14 @@ import tachiyomi.domain.library.model.LibraryDisplayMode
|
||||
import tachiyomi.domain.library.model.LibrarySort
|
||||
import tachiyomi.domain.library.model.sort
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.CheckboxItem
|
||||
import tachiyomi.presentation.core.components.HeadingItem
|
||||
import tachiyomi.presentation.core.components.SettingsChipRow
|
||||
import tachiyomi.presentation.core.components.SliderItem
|
||||
import tachiyomi.presentation.core.components.SortItem
|
||||
import tachiyomi.presentation.core.components.TriStateItem
|
||||
import tachiyomi.presentation.core.i18n.localize
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
|
||||
@Composable
|
||||
@@ -42,9 +42,9 @@ fun LibrarySettingsDialog(
|
||||
TabbedDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
tabTitles = persistentListOf(
|
||||
stringResource(R.string.action_filter),
|
||||
stringResource(R.string.action_sort),
|
||||
stringResource(R.string.action_display),
|
||||
localize(MR.strings.action_filter),
|
||||
localize(MR.strings.action_sort),
|
||||
localize(MR.strings.action_display),
|
||||
),
|
||||
) { page ->
|
||||
Column(
|
||||
@@ -75,7 +75,7 @@ private fun ColumnScope.FilterPage(
|
||||
val filterDownloaded by screenModel.libraryPreferences.filterDownloaded().collectAsState()
|
||||
val downloadedOnly by screenModel.preferences.downloadedOnly().collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.label_downloaded),
|
||||
label = localize(MR.strings.label_downloaded),
|
||||
state = if (downloadedOnly) {
|
||||
TriState.ENABLED_IS
|
||||
} else {
|
||||
@@ -86,25 +86,25 @@ private fun ColumnScope.FilterPage(
|
||||
)
|
||||
val filterUnread by screenModel.libraryPreferences.filterUnread().collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.action_filter_unread),
|
||||
label = localize(MR.strings.action_filter_unread),
|
||||
state = filterUnread,
|
||||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterUnread) },
|
||||
)
|
||||
val filterStarted by screenModel.libraryPreferences.filterStarted().collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.label_started),
|
||||
label = localize(MR.strings.label_started),
|
||||
state = filterStarted,
|
||||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterStarted) },
|
||||
)
|
||||
val filterBookmarked by screenModel.libraryPreferences.filterBookmarked().collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.action_filter_bookmarked),
|
||||
label = localize(MR.strings.action_filter_bookmarked),
|
||||
state = filterBookmarked,
|
||||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterBookmarked) },
|
||||
)
|
||||
val filterCompleted by screenModel.libraryPreferences.filterCompleted().collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.completed),
|
||||
label = localize(MR.strings.completed),
|
||||
state = filterCompleted,
|
||||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterCompleted) },
|
||||
)
|
||||
@@ -118,13 +118,13 @@ private fun ColumnScope.FilterPage(
|
||||
val service = trackers[0]
|
||||
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.action_filter_tracked),
|
||||
label = localize(MR.strings.action_filter_tracked),
|
||||
state = filterTracker,
|
||||
onClick = { screenModel.toggleTracker(service.id.toInt()) },
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
HeadingItem(R.string.action_filter_tracked)
|
||||
HeadingItem(MR.strings.action_filter_tracked)
|
||||
trackers.map { service ->
|
||||
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
||||
TriStateItem(
|
||||
@@ -149,21 +149,21 @@ private fun ColumnScope.SortPage(
|
||||
if (screenModel.trackers.isEmpty()) {
|
||||
emptyList()
|
||||
} else {
|
||||
listOf(R.string.action_sort_tracker_score to LibrarySort.Type.TrackerMean)
|
||||
listOf(MR.strings.action_sort_tracker_score to LibrarySort.Type.TrackerMean)
|
||||
}
|
||||
|
||||
listOf(
|
||||
R.string.action_sort_alpha to LibrarySort.Type.Alphabetical,
|
||||
R.string.action_sort_total to LibrarySort.Type.TotalChapters,
|
||||
R.string.action_sort_last_read to LibrarySort.Type.LastRead,
|
||||
R.string.action_sort_last_manga_update to LibrarySort.Type.LastUpdate,
|
||||
R.string.action_sort_unread_count to LibrarySort.Type.UnreadCount,
|
||||
R.string.action_sort_latest_chapter to LibrarySort.Type.LatestChapter,
|
||||
R.string.action_sort_chapter_fetch_date to LibrarySort.Type.ChapterFetchDate,
|
||||
R.string.action_sort_date_added to LibrarySort.Type.DateAdded,
|
||||
MR.strings.action_sort_alpha to LibrarySort.Type.Alphabetical,
|
||||
MR.strings.action_sort_total to LibrarySort.Type.TotalChapters,
|
||||
MR.strings.action_sort_last_read to LibrarySort.Type.LastRead,
|
||||
MR.strings.action_sort_last_manga_update to LibrarySort.Type.LastUpdate,
|
||||
MR.strings.action_sort_unread_count to LibrarySort.Type.UnreadCount,
|
||||
MR.strings.action_sort_latest_chapter to LibrarySort.Type.LatestChapter,
|
||||
MR.strings.action_sort_chapter_fetch_date to LibrarySort.Type.ChapterFetchDate,
|
||||
MR.strings.action_sort_date_added to LibrarySort.Type.DateAdded,
|
||||
).plus(trackerSortOption).map { (titleRes, mode) ->
|
||||
SortItem(
|
||||
label = stringResource(titleRes),
|
||||
label = localize(titleRes),
|
||||
sortDescending = sortDescending.takeIf { sortingMode == mode },
|
||||
onClick = {
|
||||
val isTogglingDirection = sortingMode == mode
|
||||
@@ -186,10 +186,10 @@ private fun ColumnScope.SortPage(
|
||||
}
|
||||
|
||||
private val displayModes = listOf(
|
||||
R.string.action_display_grid to LibraryDisplayMode.CompactGrid,
|
||||
R.string.action_display_comfortable_grid to LibraryDisplayMode.ComfortableGrid,
|
||||
R.string.action_display_cover_only_grid to LibraryDisplayMode.CoverOnlyGrid,
|
||||
R.string.action_display_list to LibraryDisplayMode.List,
|
||||
MR.strings.action_display_grid to LibraryDisplayMode.CompactGrid,
|
||||
MR.strings.action_display_comfortable_grid to LibraryDisplayMode.ComfortableGrid,
|
||||
MR.strings.action_display_cover_only_grid to LibraryDisplayMode.CoverOnlyGrid,
|
||||
MR.strings.action_display_list to LibraryDisplayMode.List,
|
||||
)
|
||||
|
||||
@Composable
|
||||
@@ -197,12 +197,12 @@ private fun ColumnScope.DisplayPage(
|
||||
screenModel: LibrarySettingsScreenModel,
|
||||
) {
|
||||
val displayMode by screenModel.libraryPreferences.displayMode().collectAsState()
|
||||
SettingsChipRow(R.string.action_display_mode) {
|
||||
SettingsChipRow(MR.strings.action_display_mode) {
|
||||
displayModes.map { (titleRes, mode) ->
|
||||
FilterChip(
|
||||
selected = displayMode == mode,
|
||||
onClick = { screenModel.setDisplayMode(mode) },
|
||||
label = { Text(stringResource(titleRes)) },
|
||||
label = { Text(localize(titleRes)) },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -219,43 +219,43 @@ private fun ColumnScope.DisplayPage(
|
||||
|
||||
val columns by columnPreference.collectAsState()
|
||||
SliderItem(
|
||||
label = stringResource(R.string.pref_library_columns),
|
||||
label = localize(MR.strings.pref_library_columns),
|
||||
max = 10,
|
||||
value = columns,
|
||||
valueText = if (columns > 0) {
|
||||
stringResource(R.string.pref_library_columns_per_row, columns)
|
||||
localize(MR.strings.pref_library_columns_per_row, columns)
|
||||
} else {
|
||||
stringResource(R.string.label_default)
|
||||
localize(MR.strings.label_default)
|
||||
},
|
||||
onChange = columnPreference::set,
|
||||
)
|
||||
}
|
||||
|
||||
HeadingItem(R.string.overlay_header)
|
||||
HeadingItem(MR.strings.overlay_header)
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_download_badge),
|
||||
label = localize(MR.strings.action_display_download_badge),
|
||||
pref = screenModel.libraryPreferences.downloadBadge(),
|
||||
)
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_local_badge),
|
||||
label = localize(MR.strings.action_display_local_badge),
|
||||
pref = screenModel.libraryPreferences.localBadge(),
|
||||
)
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_language_badge),
|
||||
label = localize(MR.strings.action_display_language_badge),
|
||||
pref = screenModel.libraryPreferences.languageBadge(),
|
||||
)
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_show_continue_reading_button),
|
||||
label = localize(MR.strings.action_display_show_continue_reading_button),
|
||||
pref = screenModel.libraryPreferences.showContinueReadingButton(),
|
||||
)
|
||||
|
||||
HeadingItem(R.string.tabs_header)
|
||||
HeadingItem(MR.strings.tabs_header)
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_show_tabs),
|
||||
label = localize(MR.strings.action_display_show_tabs),
|
||||
pref = screenModel.libraryPreferences.categoryTabs(),
|
||||
)
|
||||
CheckboxItem(
|
||||
label = stringResource(R.string.action_display_show_number_of_items),
|
||||
label = localize(MR.strings.action_display_show_number_of_items),
|
||||
pref = screenModel.libraryPreferences.categoryNumberOfItems(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Shadow
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import eu.kanade.presentation.manga.components.MangaCover
|
||||
import eu.kanade.tachiyomi.R
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.BadgeGroup
|
||||
import tachiyomi.presentation.core.i18n.localize
|
||||
import tachiyomi.presentation.core.util.selectedBackground
|
||||
|
||||
object CommonMangaItemDefaults {
|
||||
@@ -378,7 +378,7 @@ private fun ContinueReadingButton(
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.PlayArrow,
|
||||
contentDescription = stringResource(R.string.action_resume),
|
||||
contentDescription = localize(MR.strings.action_resume),
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.zIndex
|
||||
import eu.kanade.tachiyomi.R
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.localize
|
||||
|
||||
@Composable
|
||||
internal fun GlobalSearchItem(
|
||||
@@ -19,7 +19,7 @@ internal fun GlobalSearchItem(
|
||||
onClick = onClick,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.action_global_search_query, searchQuery),
|
||||
text = localize(MR.strings.action_global_search_query, searchQuery),
|
||||
modifier = Modifier.zIndex(99f),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.core.preference.PreferenceMutableState
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||
import tachiyomi.domain.library.model.LibraryDisplayMode
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.HorizontalPager
|
||||
import tachiyomi.presentation.core.screens.EmptyScreen
|
||||
import tachiyomi.presentation.core.util.plus
|
||||
@@ -124,9 +124,9 @@ private fun LibraryPagerEmptyScreen(
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
) {
|
||||
val msg = when {
|
||||
!searchQuery.isNullOrEmpty() -> R.string.no_results_found
|
||||
hasActiveFilters -> R.string.error_no_match
|
||||
else -> R.string.information_no_manga_category
|
||||
!searchQuery.isNullOrEmpty() -> MR.strings.no_results_found
|
||||
hasActiveFilters -> MR.strings.error_no_match
|
||||
else -> MR.strings.information_no_manga_category
|
||||
}
|
||||
|
||||
Column(
|
||||
@@ -146,7 +146,7 @@ private fun LibraryPagerEmptyScreen(
|
||||
}
|
||||
|
||||
EmptyScreen(
|
||||
textResource = msg,
|
||||
stringRes = msg,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,15 +14,15 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.sp
|
||||
import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.AppBarActions
|
||||
import eu.kanade.presentation.components.SearchToolbar
|
||||
import eu.kanade.tachiyomi.R
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.Pill
|
||||
import tachiyomi.presentation.core.i18n.localize
|
||||
import tachiyomi.presentation.core.theme.active
|
||||
|
||||
@Composable
|
||||
@@ -98,21 +98,21 @@ private fun LibraryRegularToolbar(
|
||||
AppBarActions(
|
||||
persistentListOf(
|
||||
AppBar.Action(
|
||||
title = stringResource(R.string.action_filter),
|
||||
title = localize(MR.strings.action_filter),
|
||||
icon = Icons.Outlined.FilterList,
|
||||
iconTint = filterTint,
|
||||
onClick = onClickFilter,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(R.string.action_update_library),
|
||||
title = localize(MR.strings.action_update_library),
|
||||
onClick = onClickGlobalUpdate,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(R.string.action_update_category),
|
||||
title = localize(MR.strings.action_update_category),
|
||||
onClick = onClickRefresh,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(R.string.action_open_random_manga),
|
||||
title = localize(MR.strings.action_open_random_manga),
|
||||
onClick = onClickOpenRandomManga,
|
||||
),
|
||||
),
|
||||
@@ -135,12 +135,12 @@ private fun LibrarySelectionToolbar(
|
||||
AppBarActions(
|
||||
persistentListOf(
|
||||
AppBar.Action(
|
||||
title = stringResource(R.string.action_select_all),
|
||||
title = localize(MR.strings.action_select_all),
|
||||
icon = Icons.Outlined.SelectAll,
|
||||
onClick = onClickSelectAll,
|
||||
),
|
||||
AppBar.Action(
|
||||
title = stringResource(R.string.action_select_inverse),
|
||||
title = localize(MR.strings.action_select_inverse),
|
||||
icon = Icons.Outlined.FlipToBack,
|
||||
onClick = onClickInvertSelection,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user