Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: pkg/intl/intl.dart

Issue 10939002: Fix finding locale from OS on Windows (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/intl/intl_standalone.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 /** 136 /**
137 * Return a locale name turned into xx_YY where it might possibly be 137 * Return a locale name turned into xx_YY where it might possibly be
138 * in the wrong case or with a hyphen instead of an underscore. 138 * in the wrong case or with a hyphen instead of an underscore.
139 */ 139 */
140 static String canonicalizedLocale(String aLocale) { 140 static String canonicalizedLocale(String aLocale) {
141 // Locales of length < 5 are presumably two-letter forms, or else malformed. 141 // Locales of length < 5 are presumably two-letter forms, or else malformed.
142 // Locales of length > 6 are likely to be malformed. In either case we 142 // Locales of length > 6 are likely to be malformed. In either case we
143 // return them unmodified and if correct they will be found. 143 // return them unmodified and if correct they will be found.
144 // We treat C as a special case, and assume it wants en_ISO for formatting.
145 if (aLocale == "C") return "en_ISO";
Emily Fortuna 2012/09/18 00:46:33 what does "C" mean?
Alan Knight 2012/09/18 17:08:36 It's an old Unix locale, also referred to as the P
Emily Fortuna 2012/09/18 17:38:09 Can you maybe mention a little bit of that in your
144 if ((aLocale.length < 5) || (aLocale.length > 6)) return aLocale; 146 if ((aLocale.length < 5) || (aLocale.length > 6)) return aLocale;
145 if (aLocale[2] != '-' && (aLocale[2] != '_')) return aLocale; 147 if (aLocale[2] != '-' && (aLocale[2] != '_')) return aLocale;
148 var lastRegionLetter = aLocale.length == 5 ? "" : aLocale[5].toUpperCase();
146 return '${aLocale[0]}${aLocale[1]}_${aLocale[3].toUpperCase()}' 149 return '${aLocale[0]}${aLocale[1]}_${aLocale[3].toUpperCase()}'
147 '${aLocale[4].toUpperCase()}'; 150 '${aLocale[4].toUpperCase()}$lastRegionLetter';
148 } 151 }
149 152
150 /** 153 /**
151 * Support method for message formatting. Select the correct plural form from 154 * Support method for message formatting. Select the correct plural form from
152 * [cases] given [howMany]. 155 * [cases] given [howMany].
153 */ 156 */
154 static String plural(var howMany, Map cases, [num offset=0]) { 157 static String plural(var howMany, Map cases, [num offset=0]) {
155 // TODO(efortuna): Deal with "few" and "many" cases, offset, and others! 158 // TODO(efortuna): Deal with "few" and "many" cases, offset, and others!
156 return select(howMany.toString(), cases); 159 return select(howMany.toString(), cases);
157 } 160 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 /** 212 /**
210 * Initialize the message lookup mechanism. This is for internal use only. 213 * Initialize the message lookup mechanism. This is for internal use only.
211 * User applications should import message_lookup_local.dart and call 214 * User applications should import message_lookup_local.dart and call
212 * initializeMessages 215 * initializeMessages
213 */ 216 */
214 void initializeInternalMessageLookup(Function lookupFunction) { 217 void initializeInternalMessageLookup(Function lookupFunction) {
215 if (_messageLookup is UninitializedLocaleData) { 218 if (_messageLookup is UninitializedLocaleData) {
216 _messageLookup = lookupFunction(); 219 _messageLookup = lookupFunction();
217 } 220 }
218 } 221 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/intl_standalone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698