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

Side by Side Diff: lib/src/icu_parser.dart

Issue 1151133002: Allow spaces between the identifier and the translation when parsing ARB files (Closed) Base URL: https://github.com/dart-lang/intl.git@master
Patch Set: Make it 0.12.4 Created 5 years, 7 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
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 * Contains a parser for ICU format plural/gender/select format for localized 6 * Contains a parser for ICU format plural/gender/select format for localized
7 * messages. See extract_to_arb.dart and make_hardcoded_translation.dart. 7 * messages. See extract_to_arb.dart and make_hardcoded_translation.dart.
8 */ 8 */
9 library icu_parser; 9 library icu_parser;
10 10
(...skipping 15 matching lines...) Expand all
26 get icuEscapedText => quotedCurly | twoSingleQuotes; 26 get icuEscapedText => quotedCurly | twoSingleQuotes;
27 get curly => (openCurly | closeCurly); 27 get curly => (openCurly | closeCurly);
28 get notAllowedInIcuText => curly | char("<"); 28 get notAllowedInIcuText => curly | char("<");
29 get icuText => notAllowedInIcuText.neg(); 29 get icuText => notAllowedInIcuText.neg();
30 get notAllowedInNormalText => char("{"); 30 get notAllowedInNormalText => char("{");
31 get normalText => notAllowedInNormalText.neg(); 31 get normalText => notAllowedInNormalText.neg();
32 get messageText => (icuEscapedText | icuText).plus().map((x) => x.join()); 32 get messageText => (icuEscapedText | icuText).plus().map((x) => x.join());
33 get nonIcuMessageText => normalText.plus().map((x) => x.join()); 33 get nonIcuMessageText => normalText.plus().map((x) => x.join());
34 get twoSingleQuotes => string("''").map((x) => "'"); 34 get twoSingleQuotes => string("''").map((x) => "'");
35 get number => digit().plus().flatten().trim().map(int.parse); 35 get number => digit().plus().flatten().trim().map(int.parse);
36 get id => (letter() & (word() | char("_")).star()).flatten(); 36 get id => (letter() & (word() | char("_")).star()).flatten().trim();
37 get comma => char(",").trim(); 37 get comma => char(",").trim();
38 38
39 /** 39 /**
40 * Given a list of possible keywords, return a rule that accepts any of them. 40 * Given a list of possible keywords, return a rule that accepts any of them.
41 * e.g., given ["male", "female", "other"], accept any of them. 41 * e.g., given ["male", "female", "other"], accept any of them.
42 */ 42 */
43 asKeywords(list) => list.map(string).reduce((a, b) => a | b).flatten().trim(); 43 asKeywords(list) => list.map(string).reduce((a, b) => a | b).flatten().trim();
44 44
45 get pluralKeyword => asKeywords( 45 get pluralKeyword => asKeywords(
46 ["=0", "=1", "=2", "zero", "one", "two", "few", "many", "other"]); 46 ["=0", "=1", "=2", "zero", "one", "two", "few", "many", "other"]);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 get stuff => (pluralOrGenderOrSelect | empty) 100 get stuff => (pluralOrGenderOrSelect | empty)
101 .map((chunk) => Message.from(chunk, null)); 101 .map((chunk) => Message.from(chunk, null));
102 102
103 IcuParser() { 103 IcuParser() {
104 // There is a cycle here, so we need the explicit set to avoid 104 // There is a cycle here, so we need the explicit set to avoid
105 // infinite recursion. 105 // infinite recursion.
106 interiorText.set(contents.plus() | empty); 106 interiorText.set(contents.plus() | empty);
107 } 107 }
108 } 108 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698