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

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

Issue 11091012: Clean up TODOs and comments in Intl (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 | « pkg/intl/lib/date_format.dart ('k') | pkg/intl/lib/message_lookup_local.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 * 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
11 * ways of making that data available, which may require importing different 11 * ways of making that data available, which may require importing different
12 * libraries. See the class comments for more details. 12 * libraries. See the class comments for more details.
13 * 13 *
14 * There is also a simple example application that can be found in the 14 * There is also a simple example application that can be found in the
15 * `example/basic` directory. 15 * `example/basic` directory.
16 */ 16 */
17 #library('intl'); 17 #library('intl');
18 18
19 #import('src/intl_helpers.dart'); 19 #import('src/intl_helpers.dart');
20 #import('dart:math'); 20 #import('dart:math');
21 #import('date_symbols.dart'); 21 #import('date_symbols.dart');
22 #import('src/date_format_internal.dart'); 22 #import('src/date_format_internal.dart');
23 23
24 #source('date_format.dart'); 24 #source('date_format.dart');
25 #source('src/date_format_field.dart'); 25 #source('src/date_format_field.dart');
26 #source('src/date_format_helpers.dart'); 26 #source('src/date_format_helpers.dart');
27 #source('bidi_formatter.dart'); 27 #source('bidi_formatter.dart');
28 #source('bidi_utils.dart'); 28 #source('bidi_utils.dart');
29 29
30 /**
31 * The Intl class provides a common entry point for internationalization
32 * related tasks. An Intl instance can be created for a particular locale
33 * and used to create a date format via `anIntl.date()`. Static methods
34 * on this class are also used in message formatting.
35 *
36 * Message example:
37 * '''I see ${Intl.plural(num_people,
38 * {'0': 'no one at all',
39 * '1': 'one other person',
40 * 'other': '$num_people other people'})} in $place.''''
41 *
42 * Usage examples:
43 * today(date) => intl.message(
44 * "Today's date is $date",
45 * desc: 'Indicate the current date',
46 * examples: {'date' : 'June 8, 2012'});
47 * print(today(new Date.now());
48 *
49 * msg(num_people, place) => intl.message(
50 * '''I see ${Intl.plural(num_people,
51 * {'0': 'no one at all',
52 * '1': 'one other person',
53 * 'other': '$num_people other people'})} in $place.'''',
54 * desc: 'Description of how many people are seen as program start.',
55 * examples: {'num_people': 3, 'place': 'London'});
56 *
57 * Calling `msg({'num_people': 2, 'place': 'Athens'});` would
58 * produce "I see 2 other people in Athens." as output.
59 *
60 * See `tests/message_format_test.dart` for more examples.
61 */
62 //TODO(efortuna): documentation example involving the offset parameter?
63
30 class Intl { 64 class Intl {
31 /** 65 /**
32 * String indicating the locale code with which the message is to be 66 * String indicating the locale code with which the message is to be
33 * formatted (such as en-CA). 67 * formatted (such as en-CA).
34 */ 68 */
35 String _locale; 69 String _locale;
36 70
37 /** The default locale. This defaults to being set from systemLocale, but 71 /** The default locale. This defaults to being set from systemLocale, but
38 * can also be set explicitly, and will then apply to any new instances where 72 * can also be set explicitly, and will then apply to any new instances where
39 * the locale isn't specified. 73 * the locale isn't specified.
40 */ 74 */
41 static String _defaultLocale; 75 static String _defaultLocale;
42 76
43 /** 77 /**
44 * The system's locale, as obtained from the window.navigator.language 78 * The system's locale, as obtained from the window.navigator.language
45 * or other operating system mechanism. Note that due to system limitations 79 * or other operating system mechanism. Note that due to system limitations
46 * this is not automatically set, and must be set by importing one of 80 * this is not automatically set, and must be set by importing one of
47 * intl_browser.dart or intl_standalone.dart and calling findSystemLocale(). 81 * intl_browser.dart or intl_standalone.dart and calling findSystemLocale().
48 */ 82 */
49 // TODO(alanknight): Detect this without forcing the jump through hoops.
50 // Issue 5171.
51 static String systemLocale = 'en_US'; 83 static String systemLocale = 'en_US';
52 84
53 /** 85 /**
54 * Return a new date format using the specified [pattern]. 86 * Return a new date format using the specified [pattern].
55 * If [desiredLocale] is not specified, then we default to [locale]. 87 * If [desiredLocale] is not specified, then we default to [locale].
56 */ 88 */
57 DateFormat date([String pattern, String desiredLocale]) { 89 DateFormat date([String pattern, String desiredLocale]) {
58 var actualLocale = (desiredLocale == null) ? locale : desiredLocale; 90 var actualLocale = (desiredLocale == null) ? locale : desiredLocale;
59 return new DateFormat(pattern, actualLocale); 91 return new DateFormat(pattern, actualLocale);
60 } 92 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 /** 237 /**
206 * Accessor for the current locale. This should always == the default locale, 238 * Accessor for the current locale. This should always == the default locale,
207 * unless for some reason this gets called inside a message that resets the 239 * unless for some reason this gets called inside a message that resets the
208 * locale. 240 * locale.
209 */ 241 */
210 static String getCurrentLocale() { 242 static String getCurrentLocale() {
211 if (_defaultLocale == null) _defaultLocale = systemLocale; 243 if (_defaultLocale == null) _defaultLocale = systemLocale;
212 return _defaultLocale; 244 return _defaultLocale;
213 } 245 }
214 } 246 }
OLDNEW
« no previous file with comments | « pkg/intl/lib/date_format.dart ('k') | pkg/intl/lib/message_lookup_local.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698