| 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 /// Distinguish two messages with identical text using the meaning parameter. |
| 114 rentToBePaid() => Intl.message("rent", name: "rentToBePaid", |
| 115 meaning: 'Money for rent', desc: "Money to be paid for rent"); |
| 116 |
| 117 rentAsVerb() => Intl.message("rent", name: "rentAsVerb", |
| 118 meaning: 'rent as a verb', desc: "The action of renting, as in rent a car"); |
| 119 |
| 113 printStuff(Intl locale) { | 120 printStuff(Intl locale) { |
| 114 | 121 |
| 115 // Use a name that's not a literal so this will get skipped. Then we have | 122 // 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 | 123 // 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 | 124 // translation. Because it's not in the original it shouldn't get included |
| 118 // in the generated catalog and shouldn't get translated. | 125 // in the generated catalog and shouldn't get translated. |
| 119 if (locale.locale == 'fr') { | 126 if (locale.locale == 'fr') { |
| 120 var badName = "thisNameIsNotInTheOriginal"; | 127 var badName = "thisNameIsNotInTheOriginal"; |
| 121 var notInOriginal = Intl.message("foo", name: badName); | 128 var notInOriginal = Intl.message("foo", name: badName); |
| 122 if (notInOriginal != "foo") { | 129 if (notInOriginal != "foo") { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 printOut(outerPlural(1)); | 193 printOut(outerPlural(1)); |
| 187 printOut(outerGender("male")); | 194 printOut(outerGender("male")); |
| 188 printOut(outerGender("female")); | 195 printOut(outerGender("female")); |
| 189 printOut(nestedOuter(7, "male")); | 196 printOut(nestedOuter(7, "male")); |
| 190 printOut(outerSelect("CDN", 7)); | 197 printOut(outerSelect("CDN", 7)); |
| 191 printOut(outerSelect("EUR", 5)); | 198 printOut(outerSelect("EUR", 5)); |
| 192 printOut(nestedSelect("CDN", 1)); | 199 printOut(nestedSelect("CDN", 1)); |
| 193 printOut(nestedSelect("CDN", 2)); | 200 printOut(nestedSelect("CDN", 2)); |
| 194 printOut(pluralThatFailsParsing(1)); | 201 printOut(pluralThatFailsParsing(1)); |
| 195 printOut(pluralThatFailsParsing(2)); | 202 printOut(pluralThatFailsParsing(2)); |
| 203 printOut(rentAsVerb()); |
| 204 printOut(rentToBePaid()); |
| 196 }); | 205 }); |
| 197 } | 206 } |
| 198 | 207 |
| 199 var localeToUse = 'en_US'; | 208 var localeToUse = 'en_US'; |
| 200 | 209 |
| 201 main() { | 210 main() { |
| 202 var fr = new Intl("fr"); | 211 var fr = new Intl("fr"); |
| 203 var english = new Intl("en_US"); | 212 var english = new Intl("en_US"); |
| 204 var de = new Intl("de_DE"); | 213 var de = new Intl("de_DE"); |
| 205 // Throw in an initialize of a null locale to make sure it doesn't throw. | 214 // Throw in an initialize of a null locale to make sure it doesn't throw. |
| 206 initializeMessages(null); | 215 initializeMessages(null); |
| 207 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr)); | 216 var f1 = initializeMessages(fr.locale).then((_) => printStuff(fr)); |
| 208 var f2 = initializeMessages(de.locale).then((_) => printStuff(de)); | 217 var f2 = initializeMessages(de.locale).then((_) => printStuff(de)); |
| 209 printStuff(english); | 218 printStuff(english); |
| 210 return Future.wait([f1, f2]); | 219 return Future.wait([f1, f2]); |
| 211 } | 220 } |
| OLD | NEW |