| 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 * This library provides internationalization and localization. This includes |
| 7 * date formatting, parsing, bidirectional text relative to a specific locale. | 7 * message formatting and replacement, date and number formatting and parsing, |
| 8 * and utilities for working with Bidirectional text. |
| 9 * |
| 10 * For things that require locale or other data, there are multiple different |
| 11 * ways of making that data available, which may require importing different |
| 12 * libraries. See the class comments for more details. |
| 13 * |
| 14 * There is also a simple example application that can be found in the |
| 15 * `example/basic` directory. |
| 8 */ | 16 */ |
| 9 #library('intl'); | 17 #library('intl'); |
| 10 | 18 |
| 11 #import('src/intl_helpers.dart'); | 19 #import('src/intl_helpers.dart'); |
| 12 #import('dart:math'); | 20 #import('dart:math'); |
| 13 #import('date_symbols.dart'); | 21 #import('date_symbols.dart'); |
| 14 #import('src/date_format_internal.dart'); | 22 #import('src/date_format_internal.dart'); |
| 15 | 23 |
| 16 #source('date_format.dart'); | 24 #source('date_format.dart'); |
| 17 #source('src/date_format_field.dart'); | 25 #source('src/date_format_field.dart'); |
| (...skipping 61 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 | 87 * 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 | 88 * the variables used in the interpolated string, and additionally also a |
| 81 * locale (optional). | 89 * locale (optional). |
| 82 * Ultimately, the information about the enclosing function and its arguments | 90 * Ultimately, the information about the enclosing function and its arguments |
| 83 * will be extracted automatically but for the time being it must be passed | 91 * will be extracted automatically but for the time being it must be passed |
| 84 * explicitly in the [name] and [args] arguments. | 92 * explicitly in the [name] and [args] arguments. |
| 85 */ | 93 */ |
| 86 static String message(String message_str, [final String desc='', | 94 static String message(String message_str, [final String desc='', |
| 87 final Map examples=const {}, String locale, String name, | 95 final Map examples=const {}, String locale, String name, |
| 88 List<String> args]) { | 96 List<String> args]) { |
| 89 return _messageLookup.lookupMessage( | 97 return messageLookup.lookupMessage( |
| 90 message_str, desc, examples, locale, name, args); | 98 message_str, desc, examples, locale, name, args); |
| 91 } | 99 } |
| 92 | 100 |
| 93 /** | 101 /** |
| 94 * Return the locale for this instance. If none was set, the locale will | 102 * Return the locale for this instance. If none was set, the locale will |
| 95 * be the default. | 103 * be the default. |
| 96 */ | 104 */ |
| 97 String get locale => _locale; | 105 String get locale => _locale; |
| 98 | 106 |
| 99 /** | 107 /** |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 204 |
| 197 /** | 205 /** |
| 198 * Accessor for the current locale. This should always == the default locale, | 206 * 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 | 207 * unless for some reason this gets called inside a message that resets the |
| 200 * locale. | 208 * locale. |
| 201 */ | 209 */ |
| 202 static String getCurrentLocale() { | 210 static String getCurrentLocale() { |
| 203 if (_defaultLocale == null) _defaultLocale = systemLocale; | 211 if (_defaultLocale == null) _defaultLocale = systemLocale; |
| 204 return _defaultLocale; | 212 return _defaultLocale; |
| 205 } | 213 } |
| 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 } | 214 } |
| OLD | NEW |