Skip to content

Commit

Permalink
ankidroid#12451 Issue: Replace string with plurals (ankidroid#13616)
Browse files Browse the repository at this point in the history
* Fix: ankidroid#12451 Issue: Replace string with plurals

String key pairs have been changed by adding '_new" to the key. Ex.  name = "string_key" to name = "string_key_new"

Final Updates for Plural Candidates

* disambiguate apostrophe with expansion of text

---------

Co-authored-by: Mike Hardy <[email protected]>
  • Loading branch information
2 people authored and dae committed Jun 29, 2023
1 parent 3ced5a9 commit f643883
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ open class DeckPicker :
}
val count = databaseResult.cardsWithFixedHomeDeckCount
if (count != 0) {
val message = resources.getString(R.string.integrity_check_fixed_no_home_deck, count)
val message = resources.getQuantityString(R.plurals.integrity_check_fixed_no_home_deck_new, count, count)
showThemedToast(this@DeckPicker, message, false)
}
val msg: String
Expand Down
12 changes: 7 additions & 5 deletions AnkiDroid/src/main/java/com/ichi2/anki/Sync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -554,23 +554,25 @@ fun DeckPicker.createSyncListener(isFetchingMedia: Boolean) = object : Connectio
dialogMessage = when {
diff >= 86100 -> {
// The difference if more than a day minus 5 minutes acceptable by ankiweb error
res.getString(
R.string.sync_log_clocks_unsynchronized,
res.getQuantityString(
R.plurals.sync_log_clocks_unsynchronized_new,
diff.toInt(),
diff,
res.getString(R.string.sync_log_clocks_unsynchronized_date)
)
}
abs(diff % 3600.0 - 1800.0) >= 1500.0 -> {
// The difference would be within limit if we adjusted the time by few hours
// It doesn't work for all timezones, but it covers most and it's a guess anyway
res.getString(
R.string.sync_log_clocks_unsynchronized,
res.getQuantityString(
R.plurals.sync_log_clocks_unsynchronized_new,
diff.toInt(),
diff,
res.getString(R.string.sync_log_clocks_unsynchronized_tz)
)
}
else -> {
res.getString(R.string.sync_log_clocks_unsynchronized, diff, "")
res.getQuantityString(R.plurals.sync_log_clocks_unsynchronized_new, diff.toInt(), diff, "")
}
}
showSyncErrorMessage(
Expand Down
4 changes: 3 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/async/Connection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ class Connection : BaseAsyncTask<Connection.Payload, Any, Connection.Payload>()
mediaError = if (downloadedCount == 0 && uploadedCount == 0) {
"${AnkiDroidApp.appResources.getString(R.string.sync_media_error)}\n\n${e.localizedMessage}"
} else {
"${AnkiDroidApp.appResources.getString(R.string.sync_media_partial_updated,downloadedCount,uploadedCount)}\n\n${e.localizedMessage}"
"${AnkiDroidApp.appResources.getQuantityString(R.plurals.sync_media_partial_downloaded_files,downloadedCount, downloadedCount)}\n" +
"${AnkiDroidApp.appResources.getQuantityString(R.plurals.sync_media_partial_uploaded_files,uploadedCount, uploadedCount)}\n" +
"\n${e.localizedMessage}"
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions AnkiDroid/src/main/java/com/ichi2/libanki/sync/MediaSyncer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ class MediaSyncer(
}
con.publishProgress(
String.format(
AnkiDroidApp.appResources.getString(R.string.sync_media_changes_count),
toSend
AnkiDroidApp.appResources.getQuantityString(
R.plurals.sync_media_changes_count_new,
toSend,
toSend
)
)
)
val changes = server.uploadChanges(zip)
Expand Down Expand Up @@ -246,8 +249,11 @@ class MediaSyncer(
}
con.publishProgress(
String.format(
AnkiDroidApp.appResources.getString(R.string.sync_media_downloaded_count),
mDownloadCount
AnkiDroidApp.appResources.getQuantityString(
R.plurals.sync_media_downloaded_count_new,
mDownloadCount,
mDownloadCount
)
)
)
} catch (e: IOException) {
Expand Down
5 changes: 4 additions & 1 deletion AnkiDroid/src/main/res/values/03-dialogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@
<string name="integrity_check_continue_anyway">Continue Anyway</string>
<string name="integrity_check_insufficient_space">Check Database uses a large amount of temporary storage.\n\nIt is strongly recommended that you have at least %s free space on your device before continuing.</string>
<string name="integrity_check_insufficient_space_extra_content">\n\nYou currently have %s free.</string>
<string name="integrity_check_fixed_no_home_deck">%d cards with incorrect home decks were recovered. Please see the manual for more information.</string>
<plurals name="integrity_check_fixed_no_home_deck_new">
<item quantity="one">%d card with incorrect home deck was recovered. Please see the manual for more information.</item>
<item quantity="other">%d cards with incorrect home decks were recovered. Please see the manual for more information.</item>
</plurals>

<string name="video_creation_error">Could not play video</string>

Expand Down
24 changes: 20 additions & 4 deletions AnkiDroid/src/main/res/values/04-network.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
<string name="sync_downloading_message">Downloading…</string>
<string name="sync_title">Synchronization</string>
<string name="sync_log_uploading_message">Full sync from local</string>
<string name="sync_log_clocks_unsynchronized">Your clock’s off by %1$d seconds%2$s. Make sure that the date, time, and timezone on your phone are set correctly, then sync again.</string>
<plurals name="sync_log_clocks_unsynchronized_new">
<item quantity="one">Your clock is off by %1$d second%2$s. Make sure that the date, time, and timezone on your phone are set correctly, then sync again.</item>
<item quantity="other">Your clock is off by %1$d seconds%2$s. Make sure that the date, time, and timezone on your phone are set correctly, then sync again.</item>
</plurals>
<string name="sync_log_clocks_unsynchronized_tz">, the time zone’s possibly wrong</string>
<string name="sync_log_clocks_unsynchronized_date">, the date’s possibly wrong</string>
<string name="sync_no_changes_message">No changes found</string>
Expand All @@ -80,9 +83,22 @@
<string name="sync_media_find">Finding changed media…</string>
<string name="sync_media_no_changes">No changes to media files</string>
<string name="sync_media_success">Media synced</string>
<string name="sync_media_partial_updated">Media sync partially completed:\n%1$d media files downloaded.\n%2$d media files uploaded.</string>
<string name="sync_media_changes_count">%d media changes to upload</string>
<string name="sync_media_downloaded_count">%d media files downloaded</string>
<plurals name="sync_media_partial_downloaded_files">
<item quantity="one">Media sync partially completed:\n%d media file downloaded.</item>
<item quantity="other">Media sync partially completed:\n%d media files downloaded.</item>
</plurals>
<plurals name="sync_media_partial_uploaded_files">
<item quantity="one">%d media file uploaded.</item>
<item quantity="other">%d media files uploaded.</item>
</plurals>
<plurals name="sync_media_changes_count_new">
<item quantity="one">%d media change to upload</item>
<item quantity="other">%d media changes to upload</item>
</plurals>
<plurals name="sync_media_downloaded_count_new">
<item quantity="one">%d media file downloaded</item>
<item quantity="other">%d media files downloaded</item>
</plurals>
<string name="sync_sanity_failed">After syncing, the collection was in an inconsistent state. To fix this problem, AnkiDroid will force a full sync. Choose which side you would like to keep.</string>
<string name="sync_media_sanity_failed">Media sync completed, but the media count doesn’t agree with the server. The next media sync will be full to correct any error.</string>
<string name="sync_media_db_error">Media sync failed because current database is corrupt. A media check is recommended.</string>
Expand Down

0 comments on commit f643883

Please sign in to comment.