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

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

Issue 11017057: Try removing explicit use of dynamic (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | no next file » | 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 * This library provides internationalization and localization. This includes 6 * This library provides internationalization and localization. This includes
7 * message formatting and replacement, date and number formatting and parsing, 7 * message formatting and replacement, date and number formatting and parsing,
8 * and utilities for working with Bidirectional text. 8 * and utilities for working with Bidirectional text.
9 * 9 *
10 * For things that require locale or other data, there are multiple different 10 * For things that require locale or other data, there are multiple different
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 * [message_function] that takes no parameters. The [message_function] can be 225 * [message_function] that takes no parameters. The [message_function] can be
226 * a simple message function that just returns the result of `Intl.message()` 226 * a simple message function that just returns the result of `Intl.message()`
227 * it can be a wrapper around a message function that takes arguments, or it 227 * it can be a wrapper around a message function that takes arguments, or it
228 * can be something more complex that manipulates multiple message 228 * can be something more complex that manipulates multiple message
229 * functions. 229 * functions.
230 * 230 *
231 * In either case, the purpose of this is to delay calling [message_function] 231 * In either case, the purpose of this is to delay calling [message_function]
232 * until the proper locale has been set. This returns the result of calling 232 * until the proper locale has been set. This returns the result of calling
233 * [msg_function], which could be of an arbitrary type. 233 * [msg_function], which could be of an arbitrary type.
234 */ 234 */
235 static dynamic withLocale(String locale, Function message_function) { 235 static withLocale(String locale, Function message_function) {
236 // We have to do this silliness because Locale is not known at compile time, 236 // We have to do this silliness because Locale is not known at compile time,
237 // but must be a static variable in order to be visible to the Intl.message 237 // but must be a static variable in order to be visible to the Intl.message
238 // invocation. 238 // invocation.
239 if (_defaultLocale == null) _defaultLocale = systemLocale; 239 if (_defaultLocale == null) _defaultLocale = systemLocale;
240 var oldLocale = _defaultLocale; 240 var oldLocale = _defaultLocale;
241 _defaultLocale = locale; 241 _defaultLocale = locale;
242 var result = message_function(); 242 var result = message_function();
243 _defaultLocale = oldLocale; 243 _defaultLocale = oldLocale;
244 return result; 244 return result;
245 } 245 }
(...skipping 15 matching lines...) Expand all
261 /** 261 /**
262 * Accessor for the current locale. This should always == the default locale, 262 * Accessor for the current locale. This should always == the default locale,
263 * unless for some reason this gets called inside a message that resets the 263 * unless for some reason this gets called inside a message that resets the
264 * locale. 264 * locale.
265 */ 265 */
266 static String getCurrentLocale() { 266 static String getCurrentLocale() {
267 if (_defaultLocale == null) _defaultLocale = systemLocale; 267 if (_defaultLocale == null) _defaultLocale = systemLocale;
268 return _defaultLocale; 268 return _defaultLocale;
269 } 269 }
270 } 270 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698