| Index: pkg/intl/lib/intl.dart
|
| diff --git a/pkg/intl/lib/intl.dart b/pkg/intl/lib/intl.dart
|
| index 00edd6f6c5b2cf5a2c065f73129a7df8df6757e4..e91c2b22a040d038d76deb37194002068f2c9443 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),
|
| + 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.
|
|
|