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

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

Issue 113223002: Write a README for the Intl package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
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 * ## Installing ## 10 * This is part of the [intl package]
11 * 11 * (http://pub.dartlang.org/packages/intl).
12 * Use [pub][] to install this package. Add the following to your `pubspec.yaml`
13 * file.
14 *
15 * dependencies:
16 * intl: any
17 *
18 * Then run `pub install`.
19 *
20 * For more information, see the
21 * [intl package on pub.dartlang.org](http://pub.dartlang.org/packages/intl).
22 * 12 *
23 * For things that require locale or other data, there are multiple different 13 * For things that require locale or other data, there are multiple different
24 * ways of making that data available, which may require importing different 14 * ways of making that data available, which may require importing different
25 * libraries. See the class comments for more details. 15 * libraries. See the class comments for more details.
26 * 16 *
27 * There is also a simple example application that can be found in the 17 * There is also a simple example application that can be found in the
28 * `example/basic` directory. 18 * [example/basic]
29 * 19 * (https://code.google.com/p/dart/source/browse/#svn%2Fbranches%2Fbleeding_edge %2Fdart%2Fpkg%2Fintl%2Fexample%2Fbasic)
30 * [pub]: http://pub.dartlang.org 20 * directory.
31 */ 21 */
32 library intl; 22 library intl;
33 23
34 import 'dart:collection'; 24 import 'dart:collection';
35 import 'dart:convert'; 25 import 'dart:convert';
36 import 'src/intl_helpers.dart'; 26 import 'src/intl_helpers.dart';
37 import 'dart:math'; 27 import 'dart:math';
38 import 'date_symbols.dart'; 28 import 'date_symbols.dart';
39 import 'src/date_format_internal.dart'; 29 import 'src/date_format_internal.dart';
40 import "number_symbols.dart"; 30 import "number_symbols.dart";
(...skipping 18 matching lines...) Expand all
59 * '1': 'one other person', 49 * '1': 'one other person',
60 * 'other': '$num_people other people'})} in $place.'''' 50 * 'other': '$num_people other people'})} in $place.''''
61 * 51 *
62 * Usage examples: 52 * Usage examples:
63 * today(date) => Intl.message( 53 * today(date) => Intl.message(
64 * "Today's date is $date", 54 * "Today's date is $date",
65 * name: 'today', 55 * name: 'today',
66 * args: [date], 56 * args: [date],
67 * desc: 'Indicate the current date', 57 * desc: 'Indicate the current date',
68 * examples: {'date' : 'June 8, 2012'}); 58 * examples: {'date' : 'June 8, 2012'});
69 * print(today(new DateTime.now()); 59 * print(today(new DateTime.now().toString());
70 * 60 *
71 * msg(num_people, place) => Intl.message( 61 * msg(num_people, place) => Intl.message(
72 * '''I see ${Intl.plural(num_people, 62 * '''I see ${Intl.plural(num_people,
73 * {'0': 'no one at all', 63 * {'0': 'no one at all',
74 * '1': 'one other person', 64 * '1': 'one other person',
75 * 'other': '$num_people other people'})} in $place.''', 65 * 'other': '$num_people other people'})} in $place.''',
76 * name: 'msg', 66 * name: 'msg',
77 * args: [num_people, place], 67 * args: [num_people, place],
78 * desc: 'Description of how many people are seen as program start.', 68 * desc: 'Description of how many people are seen as program start.',
79 * examples: {'num_people': 3, 'place': 'London'}); 69 * examples: {'num_people': 3, 'place': 'London'});
80 * 70 *
81 * Calling `msg(2, 'Athens');` would 71 * Calling `msg(2, 'Athens');` would
82 * produce "I see 2 other people in Athens." as output in the default locale. 72 * produce "I see 2 other people in Athens." as output in the default locale.
83 * 73 *
84 * To use a locale other than the default, use the `withLocale` function.
85 * You can set the default locale. 74 * You can set the default locale.
86 * Intl.defaultLocale = "pt_BR"; 75 * Intl.defaultLocale = "pt_BR";
87 * 76 *
88 * To temporarily use a locale other than the default, use the `withLocale` 77 * To temporarily use a locale other than the default, use the `withLocale`
89 * function. 78 * function.
90 * var todayString = new DateFormat("pt_BR").format(new DateTime.now()); 79 * var todayString = new DateFormat("pt_BR").format(new DateTime.now());
91 * print(withLocale("pt_BR", () => today(todayString)); 80 * print(withLocale("pt_BR", () => today(todayString));
92 * 81 *
93 * See `tests/message_format_test.dart` for more examples. 82 * See `tests/message_format_test.dart` for more examples.
94 */ 83 */
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 * unless for some reason this gets called inside a message that resets the 351 * unless for some reason this gets called inside a message that resets the
363 * locale. 352 * locale.
364 */ 353 */
365 static String getCurrentLocale() { 354 static String getCurrentLocale() {
366 if (defaultLocale == null) defaultLocale = systemLocale; 355 if (defaultLocale == null) defaultLocale = systemLocale;
367 return defaultLocale; 356 return defaultLocale;
368 } 357 }
369 358
370 toString() => "Intl($locale)"; 359 toString() => "Intl($locale)";
371 } 360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698