Chromium Code Reviews| Index: lib/i18n/intl.dart |
| =================================================================== |
| --- lib/i18n/intl.dart (revision 8515) |
| +++ lib/i18n/intl.dart (working copy) |
| @@ -41,15 +41,18 @@ |
| * based on one or more variables, a [desc] providing a description of usage |
| * for the [message_str], and a map of [examples] for each data element to be |
| * substituted into the message. For example, if message="Hello, $name", then |
| - * examples = {'name': 'Sparky'}. The values of [desc] and [examples] are |
| - * not used at run-time but are only made available to the translators, so |
| - * they MUST be simple Strings available at compile time: no String |
| - * interpolation or concatenation. |
| + * examples = {'name': 'Sparky'}. If not using the user's default locale, or |
| + * if the locale is not easily detectable, explicitly pass [locale]. |
| + * The values of [desc] and [examples] are not used at run-time but are only |
| + * made available to the translators, so they MUST be simple Strings available |
| + * at compile time: no String interpolation or concatenation. |
| * The expected usage of this is inside a function that takes as parameters |
| * the variables used in the interpolated string. |
| */ |
| - String message(String message_str, [final String desc='', |
| - final Map examples=const {}]) { |
| + static String message(String message_str, [final String desc='', |
| + final Map examples=const {}, |
| + String locale='']) { |
| + if (locale == '') locale = _getDefaultLocale(); |
|
Alan Knight
2012/06/11 23:07:01
This is bothering me a bit. If we're going to use
|
| return message_str; |
| } |
| @@ -59,8 +62,6 @@ |
| */ |
| static String plural(var howMany, Map cases, [num offset=0]) { |
| // TODO(efortuna): Deal with "few" and "many" cases, offset, and others! |
| - // TODO(alanknight): Should we have instance methods instead/as well? |
| - // Or have the others as statics? |
| return select(howMany.toString(), cases); |
| } |
| @@ -77,4 +78,12 @@ |
| return ''; |
| } |
| } |
| + |
| + /** |
| + * Helper to detect the locale as defined at runtime. |
| + */ |
| + static String _getDefaultLocale() { |
| + // TODO(efortuna): Detect the default locale given the user preferences. |
| + return 'en-US'; |
| + } |
| } |