Converted hardcoded pluralization strings to Android plural resources. (#176)
This commit is contained in:
parent
3f840a47c8
commit
2c03f125a9
5 changed files with 38 additions and 15 deletions
|
|
@ -1515,11 +1515,10 @@ private fun RemoveFromShelfConfirmationDialog(
|
||||||
onConfirm: () -> Unit,
|
onConfirm: () -> Unit,
|
||||||
onDismiss: () -> Unit
|
onDismiss: () -> Unit
|
||||||
) {
|
) {
|
||||||
val bookStr = pluralStringResource(id = R.plurals.book_word, count)
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
title = { Text(stringResource(R.string.dialog_remove_from_shelf)) },
|
title = { Text(stringResource(R.string.dialog_remove_from_shelf)) },
|
||||||
text = { Text(stringResource(R.string.dialog_remove_from_shelf_desc, count, bookStr, shelfName)) },
|
text = { Text(pluralStringResource(R.plurals.dialog_remove_from_shelf_desc, count, count, shelfName)) },
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = onConfirm) { Text(stringResource(R.string.action_remove)) }
|
TextButton(onClick = onConfirm) { Text(stringResource(R.string.action_remove)) }
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4330,7 +4330,7 @@ open class MainViewModel(application: Application) : AndroidViewModel(applicatio
|
||||||
_internalState.update {
|
_internalState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
bannerMessage = BannerMessage(appContext.getString(R.string.banner_books_removed_library, totalRemoved))
|
bannerMessage = BannerMessage(appContext.resources.getQuantityString(R.plurals.banner_books_removed_library, totalRemoved, totalRemoved))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.platform.UriHandler
|
import androidx.compose.ui.platform.UriHandler
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.res.pluralStringResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
import androidx.compose.ui.text.SpanStyle
|
import androidx.compose.ui.text.SpanStyle
|
||||||
|
|
@ -295,16 +296,16 @@ fun DeleteConfirmationDialog(
|
||||||
isPermanentDelete: Boolean = false,
|
isPermanentDelete: Boolean = false,
|
||||||
containsFolderItems: Boolean = false
|
containsFolderItems: Boolean = false
|
||||||
) {
|
) {
|
||||||
val title = if (isPermanentDelete) stringResource(R.string.dialog_delete_permanently) else stringResource(R.string.dialog_remove_from_recents)
|
val title = if (isPermanentDelete) pluralStringResource(R.plurals.dialog_delete_permanently, count) else stringResource(R.string.dialog_remove_from_recents)
|
||||||
|
|
||||||
val text = if (isPermanentDelete) {
|
val text = if (isPermanentDelete) {
|
||||||
if (containsFolderItems) {
|
if (containsFolderItems) {
|
||||||
stringResource(R.string.dialog_warning_folder_sync_delete)
|
stringResource(R.string.dialog_warning_folder_sync_delete)
|
||||||
} else {
|
} else {
|
||||||
stringResource(R.string.dialog_permanently_delete_desc, count)
|
pluralStringResource(R.plurals.dialog_permanently_delete_desc, count, count)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stringResource(R.string.dialog_remove_recents_desc, count)
|
pluralStringResource(R.plurals.dialog_remove_recents_desc, count, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
val confirmText = if (isPermanentDelete) stringResource(R.string.action_delete) else stringResource(R.string.action_remove)
|
val confirmText = if (isPermanentDelete) stringResource(R.string.action_delete) else stringResource(R.string.action_remove)
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,33 @@
|
||||||
<item quantity="one">%1$d result found</item>
|
<item quantity="one">%1$d result found</item>
|
||||||
<item quantity="other">%1$d results found</item>
|
<item quantity="other">%1$d results found</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
|
<plurals name="dialog_delete_permanently">
|
||||||
|
<item quantity="one">Delete File Permanently</item>
|
||||||
|
<item quantity="other">Delete Files Permanently</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
|
<!-- %1$d = number of selected files to permanently delete. -->
|
||||||
|
<plurals name="dialog_permanently_delete_desc">
|
||||||
|
<item quantity="one">Do you want to permanently delete %1$d selected file from your device? This action cannot be undone.</item>
|
||||||
|
<item quantity="other">Do you want to permanently delete %1$d selected files from your device? This action cannot be undone.</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
|
<!-- %1$d = number of selected files to remove from the recents list. -->
|
||||||
|
<plurals name="dialog_remove_recents_desc">
|
||||||
|
<item quantity="one">Do you want to remove %1$d selected file from the recent files list? It will reappear if you open it again from the library.</item>
|
||||||
|
<item quantity="other">Do you want to remove %1$d selected files from the recent files list? It will reappear if you open it again from the library.</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
|
<!-- Confirmation dialog. %1$d = count of books; %2$s = shelf name. -->
|
||||||
|
<plurals name="dialog_remove_from_shelf_desc">
|
||||||
|
<item quantity="one">Are you sure you want to remove %1$d book from the \'%2$s\' shelf? The book will remain in your library and appear under Unshelved.</item>
|
||||||
|
<item quantity="other">Are you sure you want to remove %1$d books from the \'%2$s\' shelf? The books will remain in your library and appear under Unshelved.</item>
|
||||||
|
</plurals>
|
||||||
|
|
||||||
|
<!-- %1$d = number of books removed from the library. -->
|
||||||
|
<plurals name="banner_books_removed_library">
|
||||||
|
<item quantity="one">%1$d book removed from library.</item>
|
||||||
|
<item quantity="other">%1$d books removed from library.</item>
|
||||||
|
</plurals>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -36,13 +36,9 @@
|
||||||
<string name="pin_unpin">Pin/Unpin</string>
|
<string name="pin_unpin">Pin/Unpin</string>
|
||||||
<string name="info">Info</string>
|
<string name="info">Info</string>
|
||||||
<string name="select_all">Select All</string>
|
<string name="select_all">Select All</string>
|
||||||
<string name="dialog_delete_permanently">Delete File(s) Permanently</string>
|
|
||||||
<string name="dialog_remove_from_recents">Remove from Recents</string>
|
<string name="dialog_remove_from_recents">Remove from Recents</string>
|
||||||
<string name="dialog_warning_folder_sync_delete">Warning: Some selected items are synced from a local folder. Proceeding will delete the actual files from your device storage.\n\nThis action cannot be undone.</string>
|
<string name="dialog_warning_folder_sync_delete">Warning: Some selected items are synced from a local folder. Proceeding will delete the actual files from your device storage.\n\nThis action cannot be undone.</string>
|
||||||
<!-- %1$d = number of selected files to permanently delete. -->
|
|
||||||
<string name="dialog_permanently_delete_desc">Do you want to permanently delete %1$d selected file(s) from your device? This action cannot be undone.</string>
|
|
||||||
<!-- %1$d = number of selected files to remove from the recents list. -->
|
|
||||||
<string name="dialog_remove_recents_desc">Do you want to remove %1$d selected file(s) from the recent files list? It will reappear if you open it again from the library.</string>
|
|
||||||
<string name="file_information">File Information</string>
|
<string name="file_information">File Information</string>
|
||||||
<string name="book_name">Book Name</string>
|
<string name="book_name">Book Name</string>
|
||||||
<string name="copy_name">Copy Name</string>
|
<string name="copy_name">Copy Name</string>
|
||||||
|
|
@ -153,8 +149,7 @@
|
||||||
<!-- Confirmation dialog. %1$s = name of the shelf being deleted. -->
|
<!-- Confirmation dialog. %1$s = name of the shelf being deleted. -->
|
||||||
<string name="dialog_delete_shelf_desc">Are you sure you want to delete the \'%1$s\' shelf? All books will be moved to Unshelved.</string>
|
<string name="dialog_delete_shelf_desc">Are you sure you want to delete the \'%1$s\' shelf? All books will be moved to Unshelved.</string>
|
||||||
<string name="dialog_remove_from_shelf">Remove from Shelf?</string>
|
<string name="dialog_remove_from_shelf">Remove from Shelf?</string>
|
||||||
<!-- Confirmation dialog. %1$d = count of books; %2$s = "book" or "books" (resolved from a plural); %3$s = shelf name. -->
|
|
||||||
<string name="dialog_remove_from_shelf_desc">Are you sure you want to remove %1$d %2$s from the \'%3$s\' shelf? The book(s) will remain in your library and appear under Unshelved.</string>
|
|
||||||
<!-- Dialog title when deleting multiple shelves. %1$s = shelf name(s). -->
|
<!-- Dialog title when deleting multiple shelves. %1$s = shelf name(s). -->
|
||||||
<string name="dialog_delete_shelves">Delete %1$s?</string>
|
<string name="dialog_delete_shelves">Delete %1$s?</string>
|
||||||
<!-- Dialog body when deleting multiple shelves. %1$d = count of selected shelves; %2$s = "shelf" or "shelves" (resolved from a plural). -->
|
<!-- Dialog body when deleting multiple shelves. %1$d = count of selected shelves; %2$s = "shelf" or "shelves" (resolved from a plural). -->
|
||||||
|
|
@ -508,8 +503,7 @@
|
||||||
<string name="banner_deleting_all_devices">Deleting from all devices…</string>
|
<string name="banner_deleting_all_devices">Deleting from all devices…</string>
|
||||||
<string name="banner_deletion_complete">Deletion complete.</string>
|
<string name="banner_deletion_complete">Deletion complete.</string>
|
||||||
<string name="error_cloud_sync_failed_deleted_locally">Cloud sync failed, deleted locally.</string>
|
<string name="error_cloud_sync_failed_deleted_locally">Cloud sync failed, deleted locally.</string>
|
||||||
<!-- %1$d = number of books removed from the library. -->
|
|
||||||
<string name="banner_books_removed_library">%1$d book(s) removed from library.</string>
|
|
||||||
<!-- "Text views" are PDF reflow versions of documents. -->
|
<!-- "Text views" are PDF reflow versions of documents. -->
|
||||||
<string name="banner_reflow_cache_cleared">Reflow cache & generated text views cleared.</string>
|
<string name="banner_reflow_cache_cleared">Reflow cache & generated text views cleared.</string>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue