Use of plural strings

Which I've just learned this is a nightmare for translators
This commit is contained in:
Jay 2020-01-12 11:33:08 -08:00
parent 4e1952ffaf
commit b1ae3629fd
6 changed files with 27 additions and 12 deletions

View File

@ -380,7 +380,7 @@ class BackupRestoreService : Service() {
.toString(), errors.size.toString()))
val sourceMissingCount = sourcesMissing.distinct().size
if (sourceMissingCount > 0)
content.add(getString(R.string.sources_missing, sourceMissingCount))
content.add(resources.getQuantityString(R.plurals.sources_missing, sourceMissingCount))
if (lincensedManga > 0)
content.add(getString(R.string.x_licensed_manga, lincensedManga))
val trackingErrors = trackingErrors.distinct()

View File

@ -533,7 +533,8 @@ class LibraryUpdateService(
setContentTitle(getString(R.string.notification_new_chapters))
color = ContextCompat.getColor(applicationContext, R.color.colorAccentLight)
if (updates.size > 1) {
setContentText(getString(R.string.notification_new_chapters_text, updates.size))
setContentText(resources.getQuantityText(R.plurals.notification_new_chapters_text,
updates.size))
setStyle(NotificationCompat.BigTextStyle().bigText(updates.joinToString("\n") {
it.first.title.chop(45)
}))

View File

@ -33,8 +33,8 @@ class ExtensionUpdateJob : Job() {
notify(Notifications.ID_UPDATES_TO_EXTS,
context.notification(Notifications.CHANNEL_UPDATES_TO_EXTS) {
setContentTitle(
context.getString(
R.string.update_check_notification_ext_updates, names.size
context.resources.getQuantityText(
R.plurals.update_check_notification_ext_updates, names.size
)
)
val extNames = if (names.size > 5) {

View File

@ -96,7 +96,7 @@ class SettingsAdvancedController : SettingsController() {
}, {
activity?.toast(R.string.cache_delete_error)
}, {
activity?.toast(resources?.getString(R.string.cache_deleted, deletedFiles))
activity?.toast(resources?.getQuantityString(R.plurals.cache_deleted, deletedFiles))
findPreference(CLEAR_CACHE_KEY)?.summary =
resources?.getString(R.string.used_cache, chapterCache.readableSize)
})

View File

@ -322,14 +322,20 @@
<string name="restoring_backup">Restoring backup</string>
<string name="backup_restoring_progress">Restoring (%1$d/%2$d)</string>
<string name="creating_backup">Creating backup</string>
<string name="sources_missing">Sources missing: %1$d</string>
<plurals name="sources_missing">
<item quantity="one">%d source missing</item>
<item quantity="other">%d sources missing</item>
</plurals>
<string name="x_licensed_manga">%1$d manga are now licensed and could not be restored</string>
<string name="not_logged_into">Not logged into %1$s</string>
<!-- Advanced section -->
<string name="pref_clear_chapter_cache">Clear chapter cache</string>
<string name="used_cache">Used: %1$s</string>
<string name="cache_deleted">Cache cleared. %1$d files have been deleted</string>
<plurals name="cache_deleted">
<item quantity="one">Cache cleared. %d file has been deleted</item>
<item quantity="other">Cache cleared. %d files have been deleted</item>
</plurals>
<string name="cache_delete_error">An error occurred while clearing cache</string>
<string name="pref_clear_cookies">Clear cookies</string>
<string name="cookies_cleared">Cookies cleared</string>
@ -538,8 +544,11 @@
<!-- Library update service notifications -->
<string name="notification_update_progress">Update progress: %1$d/%2$d</string>
<string name="notification_new_chapters">New chapters found</string>
<string name="notification_new_chapters_text">For %1$d titles</string>
<string name="notification_and_n_more">and %1$d more.</string>
<plurals name="notification_new_chapters_text">
<item quantity="one">For %d titles</item>
<item quantity="other">For %d titles</item>
</plurals>
<string name="notification_and_n_more">and %1$d more chapters.</string>
<string name="notification_cover_update_failed">Failed to update cover</string>
<string name="notification_first_add_to_library">Please add the manga to your library before doing this</string>
<string name="notification_not_connected_to_ac_title">Sync canceled</string>
@ -568,7 +577,10 @@
<string name="update_check_notification_download_complete">Download complete</string>
<string name="update_check_notification_download_error">Download error</string>
<string name="update_check_notification_update_available">Update available</string>
<string name="update_check_notification_ext_updates">%1$d extension updates available</string>
<plurals name="update_check_notification_ext_updates">
<item quantity="one">%d extension update available</item>
<item quantity="other">%d extension updates available</item>
</plurals>
<!--Content Description-->
<string name="description_backdrop">Backdrop image of manga</string>

View File

@ -2,6 +2,8 @@
apply plugin: 'com.github.ben-manes.versions'
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
@ -13,7 +15,7 @@ buildscript {
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
}
allprojects {