Chromium Code Reviews| Index: pkg/intl/lib/intl.dart |
| diff --git a/pkg/intl/lib/intl.dart b/pkg/intl/lib/intl.dart |
| index 00edd6f6c5b2cf5a2c065f73129a7df8df6757e4..7b642b423f8df83bbb57b25c71a67c782967b13a 100644 |
| --- a/pkg/intl/lib/intl.dart |
| +++ b/pkg/intl/lib/intl.dart |
| @@ -302,6 +302,33 @@ class Intl { |
| } |
| /** |
| + * Format a message differently depending on [choice]. We look up the value |
| + * of [choice] in [cases] and return the result, or an empty string if |
| + * it is not found. Normally used as part |
| + * of an Intl.message message that is to be translated. |
| + */ |
| + static String select(String choice, Map<String, String> cases, |
| + {String desc, Map examples, String locale, String name, |
| + List<String>args}) { |
| + // If we are passed a name and arguments, then we are operating as a |
| + // top-level message, so look up our translation by calling Intl.message |
| + // with ourselves as an argument. |
| + if (name != null) { |
| + return Intl.message( |
| + Intl.select(choice, cases), |
|
Emily Fortuna
2013/08/08 23:49:55
indent this stuff +2 more spaces.
Alan Knight
2013/08/09 17:09:16
Done.
|
| + name: name, |
| + args: args, |
| + locale: locale); |
| + } |
| + var exact = cases[choice]; |
| + if (exact != null) return exact; |
| + var other = cases["other"]; |
| + if (other == null) |
| + throw new ArgumentError("The 'other' case must be specified"); |
| + return other; |
| + } |
| + |
| + /** |
| * Format the given function with a specific [locale], given a |
| * [message_function] that takes no parameters. The [message_function] can be |
| * a simple message function that just returns the result of `Intl.message()` |
| @@ -325,17 +352,6 @@ class Intl { |
| } |
| /** |
| - * Support method for message formatting. Select the correct exact (gender, |
| - * usually) form from [cases] given the user [choice]. |
| - */ |
| - static String select(String choice, Map cases) { |
| - var exact = cases[choice]; |
| - if (exact != null) return exact; |
| - var other = cases["other"]; |
| - return (other == null) ? '' : other; |
| - } |
| - |
| - /** |
| * Accessor for the current locale. This should always == the default locale, |
| * unless for some reason this gets called inside a message that resets the |
| * locale. |