diff options
author | Elliott Hughes <enh@google.com> | 2014-05-23 13:28:33 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-11-19 16:18:45 -0800 |
commit | 1fe7d496db1ddc73289e6aae11f4dd4a970141d5 (patch) | |
tree | e69a357df9f0fee4624a14ab2a117cce47f89b4d /docs/html/guide | |
parent | 36c7f4b67326bad547f16aa6e72140bd839ab28d (diff) | |
download | frameworks_base-1fe7d496db1ddc73289e6aae11f4dd4a970141d5.zip frameworks_base-1fe7d496db1ddc73289e6aae11f4dd4a970141d5.tar.gz frameworks_base-1fe7d496db1ddc73289e6aae11f4dd4a970141d5.tar.bz2 |
Fix and be more explicit about plurals best practices.
The "one" case should always include %d. Say so, and fix our examples.
Also make it clear that developers should always provide exactly "one"
and "other".
Bug: 18429565
Change-Id: I09eb39ea6986850c3af28cca3052d319e3c97705
Diffstat (limited to 'docs/html/guide')
-rw-r--r-- | docs/html/guide/topics/resources/string-resource.jd | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/html/guide/topics/resources/string-resource.jd b/docs/html/guide/topics/resources/string-resource.jd index e2326ec..cbfa82e 100644 --- a/docs/html/guide/topics/resources/string-resource.jd +++ b/docs/html/guide/topics/resources/string-resource.jd @@ -237,7 +237,8 @@ distinctions at all, so you'll always get the <code>other</code> string. <p>The selection of which string to use is made solely based on grammatical <i>necessity</i>. In English, a string for <code>zero</code> 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", and so on). +"two books", and so on). Conversely, in Korean <i>only</i> the <code>other</code> string will +ever be used. <p>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 (and so on) are all treated like one @@ -343,7 +344,14 @@ values, with non-exhaustive examples in parentheses: <?xml version="1.0" encoding="utf-8"?> <resources> <plurals name="numberOfSongsAvailable"> - <item quantity="one">One song found.</item> + <!-- + As a developer, you should always supply "one" and "other" + strings. Your translators will know which strings are actually + needed for their language. Always include %d in "one" because + translators will need to use %d for languages where "one" + doesn't mean 1 (as explained above). + --> + <item quantity="one">%d song found.</item> <item quantity="other">%d songs found.</item> </plurals> </resources> @@ -353,7 +361,7 @@ values, with non-exhaustive examples in parentheses: <?xml version="1.0" encoding="utf-8"?> <resources> <plurals name="numberOfSongsAvailable"> - <item quantity="one">Znaleziono jedną piosenkę.</item> + <item quantity="one">Znaleziono %d piosenkę.</item> <item quantity="few">Znaleziono %d piosenki.</item> <item quantity="other">Znaleziono %d piosenek.</item> </plurals> @@ -597,4 +605,4 @@ with different types of styling applied to individual words: // and bold the entire sequence. CharSequence text = bold(italic(res.getString(R.string.hello)), color(Color.RED, res.getString(R.string.world))); -</pre>
\ No newline at end of file +</pre> |