| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // now. This should be moved, renamed, or generalized. | 114 // now. This should be moved, renamed, or generalized. |
| 115 if (newLocale == null) return systemLocale; | 115 if (newLocale == null) return systemLocale; |
| 116 if (_localeExists(newLocale)) { | 116 if (_localeExists(newLocale)) { |
| 117 return newLocale; | 117 return newLocale; |
| 118 } | 118 } |
| 119 for (var each in [canonicalizedLocale(newLocale), _shortLocale(newLocale)])
{ | 119 for (var each in [canonicalizedLocale(newLocale), _shortLocale(newLocale)])
{ |
| 120 if (_localeExists(each)) { | 120 if (_localeExists(each)) { |
| 121 return each; | 121 return each; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 throw new IllegalArgumentException("Invalid locale '$newLocale'"); | 124 throw new ArgumentError("Invalid locale '$newLocale'"); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** Return the short version of a locale name, e.g. 'en_US' => 'en' */ | 127 /** Return the short version of a locale name, e.g. 'en_US' => 'en' */ |
| 128 static String _shortLocale(String aLocale) { | 128 static String _shortLocale(String aLocale) { |
| 129 if (aLocale.length < 2) return aLocale; | 129 if (aLocale.length < 2) return aLocale; |
| 130 return aLocale.substring(0, 2).toLowerCase(); | 130 return aLocale.substring(0, 2).toLowerCase(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * Return a locale name turned into xx_YY where it might possibly be | 134 * Return a locale name turned into xx_YY where it might possibly be |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 /** | 211 /** |
| 212 * Initialize the message lookup mechanism. This is for internal use only. | 212 * Initialize the message lookup mechanism. This is for internal use only. |
| 213 * User applications should import message_lookup_local.dart and call | 213 * User applications should import message_lookup_local.dart and call |
| 214 * initializeMessages | 214 * initializeMessages |
| 215 */ | 215 */ |
| 216 void initializeInternalMessageLookup(Function lookupFunction) { | 216 void initializeInternalMessageLookup(Function lookupFunction) { |
| 217 if (_messageLookup is UninitializedLocaleData) { | 217 if (_messageLookup is UninitializedLocaleData) { |
| 218 _messageLookup = lookupFunction(); | 218 _messageLookup = lookupFunction(); |
| 219 } | 219 } |
| 220 } | 220 } |
| OLD | NEW |