| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Internationalization object providing access to message formatting objects, | 6 * Internationalization object providing access to message formatting objects, |
| 7 * date formatting, parsing, bidirectional text relative to a specific locale. | 7 * date formatting, parsing, bidirectional text relative to a specific locale. |
| 8 */ | 8 */ |
| 9 #library('intl'); | 9 #library('intl'); |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 * The expected usage of this is inside a function that takes as parameters | 79 * The expected usage of this is inside a function that takes as parameters |
| 80 * the variables used in the interpolated string, and additionally also a | 80 * the variables used in the interpolated string, and additionally also a |
| 81 * locale (optional). | 81 * locale (optional). |
| 82 * Ultimately, the information about the enclosing function and its arguments | 82 * Ultimately, the information about the enclosing function and its arguments |
| 83 * will be extracted automatically but for the time being it must be passed | 83 * will be extracted automatically but for the time being it must be passed |
| 84 * explicitly in the [name] and [args] arguments. | 84 * explicitly in the [name] and [args] arguments. |
| 85 */ | 85 */ |
| 86 static String message(String message_str, [final String desc='', | 86 static String message(String message_str, [final String desc='', |
| 87 final Map examples=const {}, String locale, String name, | 87 final Map examples=const {}, String locale, String name, |
| 88 List<String> args]) { | 88 List<String> args]) { |
| 89 return _messageLookup.lookupMessage( | 89 return messageLookup.lookupMessage( |
| 90 message_str, desc, examples, locale, name, args); | 90 message_str, desc, examples, locale, name, args); |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Return the locale for this instance. If none was set, the locale will | 94 * Return the locale for this instance. If none was set, the locale will |
| 95 * be the default. | 95 * be the default. |
| 96 */ | 96 */ |
| 97 String get locale => _locale; | 97 String get locale => _locale; |
| 98 | 98 |
| 99 /** | 99 /** |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 /** | 197 /** |
| 198 * Accessor for the current locale. This should always == the default locale, | 198 * Accessor for the current locale. This should always == the default locale, |
| 199 * unless for some reason this gets called inside a message that resets the | 199 * unless for some reason this gets called inside a message that resets the |
| 200 * locale. | 200 * locale. |
| 201 */ | 201 */ |
| 202 static String getCurrentLocale() { | 202 static String getCurrentLocale() { |
| 203 if (_defaultLocale == null) _defaultLocale = systemLocale; | 203 if (_defaultLocale == null) _defaultLocale = systemLocale; |
| 204 return _defaultLocale; | 204 return _defaultLocale; |
| 205 } | 205 } |
| 206 } | |
| 207 | |
| 208 /** | |
| 209 * The internal mechanism for looking up messages. We expect this to be set | |
| 210 * by the implementing package so that we're not dependent on its | |
| 211 * implementation. | |
| 212 */ | |
| 213 var _messageLookup = const | |
| 214 UninitializedLocaleData('initializeMessages(<locale>)'); | |
| 215 | |
| 216 /** | |
| 217 * Initialize the message lookup mechanism. This is for internal use only. | |
| 218 * User applications should import message_lookup_local.dart and call | |
| 219 * initializeMessages | |
| 220 */ | |
| 221 void initializeInternalMessageLookup(Function lookupFunction) { | |
| 222 if (_messageLookup is UninitializedLocaleData) { | |
| 223 _messageLookup = lookupFunction(); | |
| 224 } | |
| 225 } | 206 } |
| OLD | NEW |