| 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 * Message/plural format library with locale support. This can have different | 6 * Message/plural format library with locale support. This can have different |
| 7 * implementations based on the mechanism for finding the localized versions | 7 * implementations based on the mechanism for finding the localized versions |
| 8 * of messages. This version expects them to be in a library named e.g. | 8 * of messages. This version expects them to be in a library named e.g. |
| 9 * 'messages_en_US'. The prefix is set in the [initializeMessages] call, which | 9 * 'messages_en_US'. The prefix is set in the [initializeMessages] call, which |
| 10 * must be made for a locale before any lookups can be done. | 10 * must be made for a locale before any lookups can be done. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 /** | 68 /** |
| 69 * This provides an abstract class for messages looked up in generated code. | 69 * This provides an abstract class for messages looked up in generated code. |
| 70 * Each locale will have a separate subclass of this class with its set of | 70 * Each locale will have a separate subclass of this class with its set of |
| 71 * messages. See generate_localized.dart. | 71 * messages. See generate_localized.dart. |
| 72 */ | 72 */ |
| 73 abstract class MessageLookupByLibrary { | 73 abstract class MessageLookupByLibrary { |
| 74 /** Prevent infinite recursion when looking up the message. */ | 74 /** Prevent infinite recursion when looking up the message. */ |
| 75 bool _lookupInProgress = false; | 75 bool _lookupInProgress = false; |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Return true if the locale exists, or if it is null. Null is treated | |
| 79 * as meaning that we use the default locale. | |
| 80 */ | |
| 81 bool localeExists(localeName); | |
| 82 | |
| 83 /** | |
| 84 * Return the localized version of a message. We are passed the original | 78 * Return the localized version of a message. We are passed the original |
| 85 * version of the message, which consists of a | 79 * version of the message, which consists of a |
| 86 * [message_str] that will be translated, and which may be interpolated | 80 * [message_str] that will be translated, and which may be interpolated |
| 87 * based on one or more variables, a [desc] providing a description of usage | 81 * based on one or more variables, a [desc] providing a description of usage |
| 88 * for the [message_str], and a map of [examples] for each data element to be | 82 * for the [message_str], and a map of [examples] for each data element to be |
| 89 * substituted into the message. | 83 * substituted into the message. |
| 90 * | 84 * |
| 91 * For example, if message="Hello, $name", then | 85 * For example, if message="Hello, $name", then |
| 92 * examples = {'name': 'Sparky'}. If not using the user's default locale, or | 86 * examples = {'name': 'Sparky'}. If not using the user's default locale, or |
| 93 * if the locale is not easily detectable, explicitly pass [locale]. | 87 * if the locale is not easily detectable, explicitly pass [locale]. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 * Subclasses should override this to return a list of their message | 125 * Subclasses should override this to return a list of their message |
| 132 * functions. | 126 * functions. |
| 133 */ | 127 */ |
| 134 Map<String, Function> get messages; | 128 Map<String, Function> get messages; |
| 135 | 129 |
| 136 /** Subclasses should override this to return their locale, e.g. 'en_US' */ | 130 /** Subclasses should override this to return their locale, e.g. 'en_US' */ |
| 137 String get localeName; | 131 String get localeName; |
| 138 | 132 |
| 139 toString() => localeName; | 133 toString() => localeName; |
| 140 } | 134 } |
| OLD | NEW |