From fb7dc4be65f573c3c9a134c6063ca58b0a9c9693 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 4 Mar 2018 13:18:54 +0100 Subject: [PATCH] Use correct plural Summary: Some languages have more plurals than the english language. This enables translaters to select the appropriate plural form. Test Plan: No change in english Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: #kde_connect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D11001 --- res/values/strings.xml | 6 ++++-- .../SharePlugin/NotificationUpdateCallback.java | 12 +++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 26ea7693..e7fe9800 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -104,8 +104,10 @@ %1s Sending file to %1s Sending files to %1s - %1s - Sent %1$d out of %2$d files + + Sent %1$d file + Sent %1$d out of %2$d files + Received file from %1s Failed receiving file from %1s Tap to open \'%1s\' diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java index 911294b1..f41cd999 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/NotificationUpdateCallback.java @@ -81,11 +81,7 @@ class NotificationUpdateCallback extends Device.SendPackageStatusCallback { private void updateText() { String text; - if (numFiles > 1) { - text = res.getString(R.string.outgoing_files_text, sentFiles, numFiles); - } else { - text = res.getString(R.string.outgoing_file_text, device.getName()); - } + text = res.getQuantityString(R.plurals.outgoing_files_text, numFiles, sentFiles, numFiles); builder.setContentText(text); } @@ -93,11 +89,10 @@ class NotificationUpdateCallback extends Device.SendPackageStatusCallback { int icon; String title; String text; - int progress; + if (successful) { - progress = 1; if (numFiles > 1) { - text = res.getString(R.string.outgoing_files_text, sentFiles, numFiles); + text = res.getQuantityString(R.plurals.outgoing_files_text, numFiles, sentFiles, numFiles); } else { final String filename = toSend.get(0).getString("filename"); text = res.getString(R.string.sent_file_text, filename); @@ -105,7 +100,6 @@ class NotificationUpdateCallback extends Device.SendPackageStatusCallback { title = res.getString(R.string.sent_file_title, device.getName()); icon = android.R.drawable.stat_sys_upload_done; } else { - progress = 0; final String filename = toSend.get(sentFiles).getString("filename"); title = res.getString(R.string.sent_file_failed_title, device.getName()); text = res.getString(R.string.sent_file_failed_text, filename);