summaryrefslogtreecommitdiffstats
path: root/docs/html/guide
diff options
context:
space:
mode:
authorScott Main <smain@google.com>2011-07-27 11:51:16 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-27 11:51:16 -0700
commit31675e429503f334898075c5a1ae7e8f38236b0c (patch)
tree10d4a5497eeffc85db59f5dea109bfc93fbb02d2 /docs/html/guide
parent91f6ae57f7fbfbe4475ff72632f38eb245ef64d1 (diff)
parent71825f49d70d54b581ff2680971554974dd3ae99 (diff)
downloadframeworks_base-31675e429503f334898075c5a1ae7e8f38236b0c.zip
frameworks_base-31675e429503f334898075c5a1ae7e8f38236b0c.tar.gz
frameworks_base-31675e429503f334898075c5a1ae7e8f38236b0c.tar.bz2
Merge "cherrypick Change-Id: I48dad721d5c4d05d6026a886bb5d3b03d2ad036c docs: add info to plural strings about using string formats"
Diffstat (limited to 'docs/html/guide')
-rw-r--r--docs/html/guide/topics/resources/string-resource.jd20
1 files changed, 14 insertions, 6 deletions
diff --git a/docs/html/guide/topics/resources/string-resource.jd b/docs/html/guide/topics/resources/string-resource.jd
index 2db38f1..c8a4d8f 100644
--- a/docs/html/guide/topics/resources/string-resource.jd
+++ b/docs/html/guide/topics/resources/string-resource.jd
@@ -107,7 +107,7 @@ ID.</dd>
String string = {@link android.content.Context#getString(int) getString}(R.string.hello);
</pre>
<p>You can use either {@link android.content.Context#getString(int)} or
-{@link android.content.Context#getText(int)} to retieve a string. {@link
+{@link android.content.Context#getText(int)} to retrieve a string. {@link
android.content.Context#getText(int)} will retain any rich text styling applied to the string.</p>
</dd> <!-- end example -->
@@ -233,9 +233,9 @@ the appropriate resource for you.
<p>Note that the selection is made based on grammatical necessity. A string for <code>zero</code>
in English will be ignored even if the quantity is 0, because 0 isn't grammatically different
-from 2, or any other number except 1 ("zero books", "one book", "two books", et cetera).
+from 2, or any other number except 1 ("zero books", "one book", "two books", and so on).
Don't be misled either by the fact that, say, <code>two</code> sounds like it could only apply to
-the quantity 2: a language may require that 2, 12, 102 (et cetera) are all treated like one
+the quantity 2: a language may require that 2, 12, 102 (and so on) are all treated like one
another but differently to other quantities. Rely on your translator to know what distinctions
their language actually insists upon.
@@ -358,9 +358,17 @@ values, with non-exhaustive examples in parentheses:
<pre>
int count = getNumberOfsongsAvailable();
Resources res = {@link android.content.Context#getResources()};
-String songsFound = res.{@link android.content.res.Resources#getQuantityString(int,int)
-getQuantityString}(R.plurals.numberOfSongsAvailable, count);
+String songsFound = res.{@link android.content.res.Resources#getQuantityString(int,int,int)
+getQuantityString}(R.plurals.numberOfSongsAvailable, count, count);
</pre>
+<p>When using the {@link android.content.res.Resources#getQuantityString(int,int,int)
+getQuantityString()} method, you need to pass the {@code count} twice if your string includes
+<a href="#FormattingAndStyling">string formatting</a> with a number. For example, for the string
+{@code %d songs found}, the first {@count} parameter selects the appropriate plural string and the
+second {@count} parameter is inserted into the {@code %d} placeholder. If your plural strings do not
+include string formatting, you don't need to pass the third parameter to {@link
+android.content.res.Resources#getQuantityString(int,int)
+getQuantityString}.</p>
</dd> <!-- end example -->
</dl>
@@ -405,7 +413,7 @@ your format arguments in the string resource. For example, with the following re
</pre>
<p>In this example, the format string has two arguments: {@code %1$s} is a string and {@code %2$d}
-is a decimal number. You can format the string with arguements from your application like this:</p>
+is a decimal number. You can format the string with arguments from your application like this:</p>
<pre>
Resources res = {@link android.content.Context#getResources()};