diff options
author | Eric Fischer <enf@google.com> | 2009-06-12 16:06:37 -0700 |
---|---|---|
committer | Eric Fischer <enf@google.com> | 2009-06-12 16:06:37 -0700 |
commit | 7351dd113f26580f3bcc7500746f3a26aecc4260 (patch) | |
tree | bae02d50ea6fcbf56de5cab24178cb4d4521ae88 /core | |
parent | 7504da036834a661684185ef11ec2ec50a18ce1b (diff) | |
download | frameworks_base-7351dd113f26580f3bcc7500746f3a26aecc4260.zip frameworks_base-7351dd113f26580f3bcc7500746f3a26aecc4260.tar.gz frameworks_base-7351dd113f26580f3bcc7500746f3a26aecc4260.tar.bz2 |
Use locale-appropriate formatting to display application sizes like "252KB".
In particular allow the French and Polish translators to put a space between
the number and the unit.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/text/format/Formatter.java | 10 | ||||
-rw-r--r-- | core/res/res/values-fr/strings.xml | 1 | ||||
-rw-r--r-- | core/res/res/values/strings.xml | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/core/java/android/text/format/Formatter.java b/core/java/android/text/format/Formatter.java index 1b30aa0..367b26c 100644 --- a/core/java/android/text/format/Formatter.java +++ b/core/java/android/text/format/Formatter.java @@ -59,9 +59,15 @@ public final class Formatter { result = result / 1024; } if (result < 100) { - return String.format("%.2f%s", result, context.getText(suffix).toString()); + String value = String.format("%.2f", result); + return context.getResources(). + getString(com.android.internal.R.string.fileSizeSuffix, + value, context.getString(suffix)); } - return String.format("%.0f%s", result, context.getText(suffix).toString()); + String value = String.format("%.0f", result); + return context.getResources(). + getString(com.android.internal.R.string.fileSizeSuffix, + value, context.getString(suffix)); } /** diff --git a/core/res/res/values-fr/strings.xml b/core/res/res/values-fr/strings.xml index e85b14c..0011c45 100644 --- a/core/res/res/values-fr/strings.xml +++ b/core/res/res/values-fr/strings.xml @@ -21,6 +21,7 @@ <string name="gigabyteShort">"Go"</string> <string name="terabyteShort">"To"</string> <string name="petabyteShort">"Po"</string> + <string name="fileSizeSuffix"><xliff:g id="number" example="123">%1$s</xliff:g> <xliff:g id="unit" example="KB">%2$s</xliff:g></string> <string name="untitled">"<sans titre>"</string> <string name="ellipsis">"…"</string> <string name="emptyPhoneNumber">"(Aucun numéro de téléphone)"</string> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 79dc1ba..6f5b29a 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -30,6 +30,11 @@ <string name="terabyteShort">TB</string> <!-- Suffix added to a number to signify size in petabytes. --> <string name="petabyteShort">PB</string> + <!-- Format string used to add a suffix like "KB" or "MB" to a number + to display a size in kilobytes, megabytes, or other size units. + Some languages (like French) will want to add a space between + the placeholders. --> + <string name="fileSizeSuffix"><xliff:g id="number" example="123">%1$s</xliff:g><xliff:g id="unit" example="KB">%2$s</xliff:g></string> <!-- Used in Contacts for a field that has no label and in Note Pad for a note with no name. --> |