From f3612edb73cc4342a0891c4a18b794ef34a4900b Mon Sep 17 00:00:00 2001 From: Logan Date: Thu, 12 Feb 2015 11:17:05 +0800 Subject: [PATCH] use plurals --- res/values/strings.xml | 43 ++++++++++++------- .../seafile/seadroid2/data/DataManager.java | 6 +-- .../MultiFileChooserActivity.java | 3 +- .../MultipleImageSelectionActivity.java | 3 +- .../UnlockGesturePasswordActivity.java | 6 +-- 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 474b0f8c2..9b53833e2 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,5 @@ - + Seafile http://seafile.com Welcome to Seafile @@ -85,7 +85,11 @@ No image found Choose photos/videos to upload Select items to upload - %d items selected + + %1$d item selected + %1$d items selected + + Please enter the name of the folder Please enter the name of the file Please enter the password @@ -159,7 +163,10 @@ Select files to upload Storage was removed Error when selecting file - %d file(s) selected + + %1$d file selected + %1$d files selected + Empty folder Choose a file Security check failed @@ -193,7 +200,7 @@ Account User info - loading... + loading… Space used Sign out Click to sign out @@ -210,9 +217,15 @@ Pattern detected Forgot password Failed 5 times, please wait 30 seconds before trying - You can retry %d seconds later - Incorrect pattern, you can try another %d times - Linking points not long enough, please try again + + You can retry %1$d second later + You can retry %1$d seconds later + + + Incorrect pattern, you can try another %1$d time + Incorrect pattern, you can try another %1$d times + + Linking points not long enough, pelase try again Retry Next OK @@ -274,13 +287,13 @@ 0 KB - Pull to refresh… - Release to refresh… - Loading… + Pull to refresh… + Release to refresh… + Loading… Last update:  -  seconds ago -  minutes ago -  hours ago + %d seconds ago + %d minutes ago + %d hours ago Could not open file %s. @@ -296,9 +309,9 @@ Server should starts with either http:// or https:// Error:  Shibboleth Login - Input server... + Input server… Login with Shibboleth - loading... + loading… Network connection error, please try again later! diff --git a/src/com/seafile/seadroid2/data/DataManager.java b/src/com/seafile/seadroid2/data/DataManager.java index 9888e7b27..295694678 100644 --- a/src/com/seafile/seadroid2/data/DataManager.java +++ b/src/com/seafile/seadroid2/data/DataManager.java @@ -783,7 +783,7 @@ public String getLastPullToRefreshTime(String whichFragment) { sb.append(SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update)); if (seconds < 60) { - sb.append(seconds + SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update_seconds_ago)); + sb.append(SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update_seconds_ago, seconds)); } else { int minutes = (seconds / 60); if (minutes > 60) { @@ -792,11 +792,11 @@ public String getLastPullToRefreshTime(String whichFragment) { Date date = new Date(lastUpdate); sb.append(ptrDataFormat.format(date)); } else { - sb.append(hours + SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update_hours_ago)); + sb.append(SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update_hours_ago, hours)); } } else { - sb.append(minutes + SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update_minutes_ago)); + sb.append(SeadroidApplication.getAppContext().getString(R.string.pull_to_refresh_last_update_minutes_ago, minutes)); } } return sb.toString(); diff --git a/src/com/seafile/seadroid2/fileschooser/MultiFileChooserActivity.java b/src/com/seafile/seadroid2/fileschooser/MultiFileChooserActivity.java index 44a6ba2fc..a73b19b9b 100644 --- a/src/com/seafile/seadroid2/fileschooser/MultiFileChooserActivity.java +++ b/src/com/seafile/seadroid2/fileschooser/MultiFileChooserActivity.java @@ -141,8 +141,7 @@ private void updateSelectionStatus() { if (nSelected == 0) { status = getResources().getString(R.string.select_upload_files); } else { - status = String.format(getResources().getString(R.string.n_upload_files_selected), - nSelected); + status = getResources().getQuantityString(R.plurals.n_upload_files_selected, nSelected, nSelected); } mFooterFragment.getStatusView().setText(status); } diff --git a/src/com/seafile/seadroid2/gallery/MultipleImageSelectionActivity.java b/src/com/seafile/seadroid2/gallery/MultipleImageSelectionActivity.java index 429c1684a..6aca7b33e 100644 --- a/src/com/seafile/seadroid2/gallery/MultipleImageSelectionActivity.java +++ b/src/com/seafile/seadroid2/gallery/MultipleImageSelectionActivity.java @@ -585,8 +585,7 @@ private void updateSelectionStatus() { if (nSelected == 0) { status = getResources().getString(R.string.select_upload_items); } else { - status = String.format(getResources().getString(R.string.n_upload_items_selected), - nSelected); + status = getResources().getQuantityString(R.plurals.n_upload_items_selected, nSelected, nSelected); } mSelectionStatus.setText(status); } diff --git a/src/com/seafile/seadroid2/ui/activity/UnlockGesturePasswordActivity.java b/src/com/seafile/seadroid2/ui/activity/UnlockGesturePasswordActivity.java index 8b0d88282..a554fc98a 100644 --- a/src/com/seafile/seadroid2/ui/activity/UnlockGesturePasswordActivity.java +++ b/src/com/seafile/seadroid2/ui/activity/UnlockGesturePasswordActivity.java @@ -105,8 +105,8 @@ public void onPatternDetected(List pattern) { - mFailedPatternAttemptsSinceLastTimeout; if (retry >= 0) { if (retry == 0) - ToastUtils.show(UnlockGesturePasswordActivity.this, getResources().getString(R.string.lockscreen_access_pattern_failure)); - mHeadTextView.setText(getResources().getString(R.string.lockscreen_access_pattern_failure_left_try_times, retry)); + ToastUtils.show(UnlockGesturePasswordActivity.this, getResources().getString(R.string.lockscreen_access_pattern_failure)); + mHeadTextView.setText(getResources().getQuantityString(R.plurals.lockscreen_access_pattern_failure_left_try_times, retry, retry)); mHeadTextView.setTextColor(Color.RED); mHeadTextView.startAnimation(mShakeAnim); } @@ -143,7 +143,7 @@ public void run() { public void onTick(long millisUntilFinished) { int secondsRemaining = (int) (millisUntilFinished / 1000) - 1; if (secondsRemaining > 0) { - mHeadTextView.setText(getResources().getString(R.string.lockscreen_access_pattern_failure_left_try_seconds, secondsRemaining)); + mHeadTextView.setText(getResources().getQuantityString(R.plurals.lockscreen_access_pattern_failure_left_try_seconds, secondsRemaining, secondsRemaining)); } else { mHeadTextView.setText(R.string.lockscreen_access_pattern_hint); mHeadTextView.setTextColor(Color.WHITE);