summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorScott Main <smain@google.com>2011-07-14 10:24:18 -0700
committerScott Main <smain@google.com>2011-07-27 11:50:00 -0700
commit71825f49d70d54b581ff2680971554974dd3ae99 (patch)
tree77c237920d127950b513f4fc4eca3a0ecc2202f7 /docs
parent56def45c1ee104f87d649d6714c9caa1dfa3b339 (diff)
downloadframeworks_base-71825f49d70d54b581ff2680971554974dd3ae99.zip
frameworks_base-71825f49d70d54b581ff2680971554974dd3ae99.tar.gz
frameworks_base-71825f49d70d54b581ff2680971554974dd3ae99.tar.bz2
cherrypick Change-Id: I48dad721d5c4d05d6026a886bb5d3b03d2ad036c
docs: add info to plural strings about using string formats Change-Id: Id02c3ed8215869724092ce143e71142238098358
Diffstat (limited to 'docs')
-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()};