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

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

Issue 341793004: Update Intl date and number formatting to CLDR 25. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes Created 6 years, 5 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/test/number_test_data.dart ('k') | 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 * A utility program to take locale data represented as a Dart map whose keys 6 * A utility program to take locale data represented as a Dart map whose keys
7 * are locale names and write it into individual JSON files named by locale. 7 * are locale names and write it into individual JSON files named by locale.
8 * This should be run any time the locale data changes. 8 * This should be run any time the locale data changes.
9 * 9 *
10 * The files are written under "data/dates", in two subdirectories, "symbols" 10 * The files are written under "data/dates", in two subdirectories, "symbols"
11 * and "patterns". In "data/dates" it will also generate "localeList.dart", 11 * and "patterns". In "data/dates" it will also generate "locale_list.dart",
12 * which is sourced by the date_symbol_data... files. 12 * which is sourced by the date_symbol_data... files.
13 */ 13 */
14 14
15 import '../lib/date_symbol_data_local.dart'; 15 import '../lib/date_symbol_data_local.dart';
16 import '../lib/date_time_patterns.dart'; 16 import '../lib/date_time_patterns.dart';
17 import '../lib/intl.dart'; 17 import '../lib/intl.dart';
18 import 'dart:convert'; 18 import 'dart:convert';
19 import 'dart:io'; 19 import 'dart:io';
20 import '../test/data_directory.dart'; 20 import '../test/data_directory.dart';
21 import 'package:path/path.dart' as path; 21 import 'package:path/path.dart' as path;
22 22
23 main() { 23 main() {
24 initializeDateFormatting("en_IGNORED", null); 24 initializeDateFormatting("en_IGNORED", null);
25 writeSymbolData(); 25 writeSymbolData();
26 writePatternData(); 26 writePatternData();
27 writeLocaleList(); 27 writeLocaleList();
28 } 28 }
29 29
30 void writeLocaleList() { 30 void writeLocaleList() {
31 var file = new File(path.join(dataDirectory, 'localeList.dart')); 31 var file = new File(path.join(dataDirectory, 'locale_list.dart'));
32 var output = file.openWrite(); 32 var output = file.openWrite();
33 output.write( 33 output.write(
34 '// Copyright (c) 2012, the Dart project authors. Please see the ' 34 '// Copyright (c) 2012, the Dart project authors. Please see the '
35 'AUTHORS file\n// for details. All rights reserved. Use of this source' 35 'AUTHORS file\n// for details. All rights reserved. Use of this source'
36 'code is governed by a\n// BSD-style license that can be found in the' 36 'code is governed by a\n// BSD-style license that can be found in the'
37 ' LICENSE file.\n\n' 37 ' LICENSE file.\n\n'
38 'part of date_symbol_data_json;\n\n'
39 '/// Hard-coded list of all available locales for dates.\n'); 38 '/// Hard-coded list of all available locales for dates.\n');
40 output.write('final availableLocalesForDateFormatting = const ['); 39 output.write('final availableLocalesForDateFormatting = const [');
41 List<String> allLocales = DateFormat.allLocalesWithSymbols(); 40 List<String> allLocales = DateFormat.allLocalesWithSymbols();
42 allLocales.forEach((locale) { 41 allLocales.forEach((locale) {
43 output.write('"$locale"'); 42 output.write('"$locale"');
44 if (locale == allLocales.last) { 43 if (locale == allLocales.last) {
45 output.write('];'); 44 output.write('];');
46 } else { 45 } else {
47 output.write(',\n '); 46 output.write(',\n ');
48 } 47 }
(...skipping 19 matching lines...) Expand all
68 } 67 }
69 68
70 void writePatterns(locale, patterns) { 69 void writePatterns(locale, patterns) {
71 var file = new File(path.join(dataDirectory, 'patterns', '${locale}.json')); 70 var file = new File(path.join(dataDirectory, 'patterns', '${locale}.json'));
72 file.openWrite()..write(JSON.encode(patterns))..close(); 71 file.openWrite()..write(JSON.encode(patterns))..close();
73 } 72 }
74 73
75 void writeToJSON(dynamic data, IOSink out) { 74 void writeToJSON(dynamic data, IOSink out) {
76 out.write(JSON.encode(data.serializeToMap())); 75 out.write(JSON.encode(data.serializeToMap()));
77 } 76 }
OLDNEW
« no previous file with comments | « pkg/intl/test/number_test_data.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698