better i18n handling

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2022-07-06 14:05:43 +02:00
parent c5302e943d
commit 85a645d3a4
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
3 changed files with 32 additions and 28 deletions

View file

@ -74,7 +74,7 @@ class FilesExportWork(
// check if storage is left
if (!FileStorageUtils.checkIfEnoughSpace(ocFile)) {
showErrorNotification(successfulExports, fileIDs.size)
showErrorNotification(successfulExports)
break
}
@ -82,7 +82,7 @@ class FilesExportWork(
try {
exportFile(ocFile)
} catch (e: java.lang.RuntimeException) {
showErrorNotification(successfulExports, fileIDs.size)
showErrorNotification(successfulExports)
}
} else {
downloadFile(ocFile)
@ -112,31 +112,28 @@ class FilesExportWork(
appContext.startService(i)
}
private fun showErrorNotification(successfulExports: Int, size: Int) {
private fun showErrorNotification(successfulExports: Int) {
if (successfulExports == 0) {
showNotification(
appContext.getString(
R.string.export_failed,
appContext.resources.getQuantityString(R.plurals.files, size)
)
appContext.resources.getQuantityString(R.plurals.export_failed, successfulExports, successfulExports)
)
} else {
showNotification(
appContext.getString(
R.string.export_partially_failed,
appContext.resources.getQuantityString(R.plurals.files, successfulExports),
appContext.resources.getQuantityString(R.plurals.files, size)
appContext.resources.getQuantityString(
R.plurals.export_partially_failed,
successfulExports,
successfulExports
)
)
}
}
private fun showSuccessNotification(successfulExports: Int) {
val files = appContext.resources.getQuantityString(R.plurals.files, successfulExports, successfulExports)
showNotification(
appContext.getString(
R.string.export_successful,
files
appContext.resources.getQuantityString(
R.plurals.export_successful,
successfulExports,
successfulExports
)
)
}

View file

@ -1041,12 +1041,11 @@ public class FileOperationsHelper {
BackgroundJobManager backgroundJobManager) {
if (context != null && view != null) {
DisplayUtils.showSnackMessage(view,
context.getString(
R.string.export_start,
context.getResources().getQuantityString(R.plurals.files,
files.size(),
files.size())
));
context.getResources().getQuantityString(
R.plurals.export_start,
files.size(),
files.size()
));
}
backgroundJobManager.startImmediateFilesExportJob(files);

View file

@ -200,9 +200,21 @@
<item quantity="one">Found %d duplicate entry.</item>
<item quantity="other">Found %d duplicate entries.</item>
</plurals>
<plurals name="files">
<item quantity="one">%d file</item>
<item quantity="other">%d files</item>
<plurals name="export_successful">
<item quantity="one">Exported %d file</item>
<item quantity="other">Exported %d files</item>
</plurals>
<plurals name="export_failed">
<item quantity="one">Failed to export %d file</item>
<item quantity="other">Failed to export %d files</item>
</plurals>
<plurals name="export_partially_failed">
<item quantity="one">Exported %d file, skipped rest due to error</item>
<item quantity="other">Exported %d files, skipped rest due to error</item>
</plurals>
<plurals name="export_start">
<item quantity="one">%d file will be exported. See notification for details.</item>
<item quantity="other">%d files will be exported. See notification for details.</item>
</plurals>
<string name="sync_foreign_files_forgotten_explanation">As of version 1.3.16, files uploaded from this device are copied into the local %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to this change, all files uploaded with earlier versions of this app were copied into the %2$s folder. However, an error prevented the completion of this operation during account synchronization. You may either leave the file(s) as is and delete the link to %3$s, or move the file(s) into the %1$s folder and retain the link to %4$s.\n\nListed below are the local file(s), and the remote file(s) in %5$s they were linked to.</string>
<string name="sync_current_folder_was_removed">The folder %1$s does not exist anymore</string>
@ -1020,8 +1032,4 @@
<string name="lock_expiration_info">Expires: %1$s</string>
<string name="filedetails_export">Export</string>
<string name="locate_folder">Locate folder</string>
<string name="export_successful">Exported %1s</string>
<string name="export_failed">Failed to export %1s</string>
<string name="export_partially_failed">Exported %1s, skipped %2s due to error</string>
<string name="export_start">%1s will be exported. See notification for details.</string>
</resources>