| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 is a program with various [Intl.message] messages. It just prints | 6 * This is a program with various [Intl.message] messages. It just prints |
| 7 * all of them, and is used for testing of message extraction, translation, | 7 * all of them, and is used for testing of message extraction, translation, |
| 8 * and code generation. | 8 * and code generation. |
| 9 */ | 9 */ |
| 10 library sample; | 10 library sample; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 name: "nestedSelect", | 103 name: "nestedSelect", |
| 104 args: [currency, amount]); | 104 args: [currency, amount]); |
| 105 | 105 |
| 106 // A trivial nested plural/gender where both are done directly rather than | 106 // A trivial nested plural/gender where both are done directly rather than |
| 107 // in interpolations. | 107 // in interpolations. |
| 108 nestedOuter(number, gen) => Intl.plural(number, | 108 nestedOuter(number, gen) => Intl.plural(number, |
| 109 other: Intl.gender(gen, male: "$number male", other: "$number other"), | 109 other: Intl.gender(gen, male: "$number male", other: "$number other"), |
| 110 name: 'nestedOuter', | 110 name: 'nestedOuter', |
| 111 args: [number, gen]); | 111 args: [number, gen]); |
| 112 | 112 |
| 113 sameContentsDifferentName() => Intl.message("Hello World", |
| 114 name: "sameContentsDifferentName", |
| 115 desc: "One of two messages with the same contents, but different names"); |
| 116 |
| 117 differentNameSameContents() => Intl.message("Hello World", |
| 118 name: "differentNameSameContents", |
| 119 desc: "One of two messages with the same contents, but different names"); |
| 120 |
| 113 printStuff(Intl locale) { | 121 printStuff(Intl locale) { |
| 114 | 122 |
| 115 // Use a name that's not a literal so this will get skipped. Then we have | 123 // Use a name that's not a literal so this will get skipped. Then we have |
| 116 // a name that's not in the original but we include it in the French | 124 // a name that's not in the original but we include it in the French |
| 117 // translation. Because it's not in the original it shouldn't get included | 125 // translation. Because it's not in the original it shouldn't get included |
| 118 // in the generated catalog and shouldn't get translated. | 126 // in the generated catalog and shouldn't get translated. |
| 119 if (locale.locale == 'fr') { | 127 if (locale.locale == 'fr') { |
| 120 var badName = "thisNameIsNotInTheOriginal"; | 128 var badName = "thisNameIsNotInTheOriginal"; |
| 121 var notInOriginal = Intl.message("foo", name: badName); | 129 var notInOriginal = Intl.message("foo", name: badName); |
| 122 if (notInOriginal != "foo") { | 130 if (notInOriginal != "foo") { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 printOut(outerPlural(1)); | 194 printOut(outerPlural(1)); |
| 187 printOut(outerGender("male")); | 195 printOut(outerGender("male")); |
| 188 printOut(outerGender("female")); | 196 printOut(outerGender("female")); |
| 189 printOut(nestedOuter(7, "male")); | 197 printOut(nestedOuter(7, "male")); |
| 190 printOut(outerSelect("CDN", 7)); | 198 printOut(outerSelect("CDN", 7)); |
| 191 printOut(outerSelect("EUR", 5)); | 199 printOut(outerSelect("EUR", 5)); |
| 192 printOut(nestedSelect("CDN", 1)); | 200 printOut(nestedSelect("CDN", 1)); |
| 193 printOut(nestedSelect("CDN", 2)); | 201 printOut(nestedSelect("CDN", 2)); |
| 194 printOut(pluralThatFailsParsing(1)); | 202 printOut(pluralThatFailsParsing(1)); |
| 195 printOut(pluralThatFailsParsing(2)); | 203 printOut(pluralThatFailsParsing(2)); |
| 204 printOut(differentNameSameContents()); |
| 205 printOut(sameContentsDifferentName()); |
| 196 }); | 206 }); |
| 197 } | 207 } |
| 198 | 208 |
| 199 var localeToUse = 'en_US'; | 209 var localeToUse = 'en_US'; |
| 200 | 210 |
| 201 main() { | 211 main() { |
| 202 var fr = new Intl("fr"); | 212 var fr = new Intl("fr"); |
| 203 var english = new Intl("en_US"); | 213 var english = new Intl("en_US"); |
| 204 var de = new Intl("de_DE"); | 214 var de = new Intl("de_DE"); |
| 205 // Throw in an initialize of a null locale to make sure it doesn't throw. | 215 // Throw in an initialize of a null locale to make sure it doesn't throw. |
| 206 initializeMessages(null); | 216 initializeMessages(null); |
| 207 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr)); | 217 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr)); |
| 208 var f2 = initializeMessages(de.locale).then((_) => printStuff(de)); | 218 var f2 = initializeMessages(de.locale).then((_) => printStuff(de)); |
| 209 printStuff(english); | 219 printStuff(english); |
| 210 return Future.wait([f1, f2]); | 220 return Future.wait([f1, f2]); |
| 211 } | 221 } |
| OLD | NEW |