| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * This simulates a translation process, reading the messages generated | 7 * This simulates a translation process, reading the messages generated |
| 8 * from extract_message.dart for the files sample_with_messages.dart and | 8 * from extract_message.dart for the files sample_with_messages.dart and |
| 9 * part_of_sample_with_messages.dart and writing out hard-coded translations for | 9 * part_of_sample_with_messages.dart and writing out hard-coded translations for |
| 10 * German and French locales. | 10 * German and French locales. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 ["other", "\${names} étaient allés à la \$place"], | 77 ["other", "\${names} étaient allés à la \$place"], |
| 78 ], null) | 78 ], null) |
| 79 ], | 79 ], |
| 80 ["female", new Plural.from("number", | 80 ["female", new Plural.from("number", |
| 81 [ | 81 [ |
| 82 ["one", "\$names était allée à la \$place"], | 82 ["one", "\$names était allée à la \$place"], |
| 83 ["other", "\$names étaient allées à la \$place"], | 83 ["other", "\$names étaient allées à la \$place"], |
| 84 ], null) | 84 ], null) |
| 85 ] | 85 ] |
| 86 ], null | 86 ], null |
| 87 )) | 87 )), |
| 88 "outerPlural" : writer.write(new Plural.from("n", |
| 89 [ |
| 90 ['zero', 'rien'], |
| 91 ['one', 'un'], |
| 92 ['other', 'quelques-uns'] |
| 93 ], null)), |
| 94 "outerGender" : writer.write(new Gender.from("g", |
| 95 [ |
| 96 ['male', 'homme'], |
| 97 ['female', 'femme'], |
| 98 ['other', 'autre'], |
| 99 ], null)), |
| 100 "nestedOuter" : writer.write ( new Plural.from("number", |
| 101 [ |
| 102 ['other', new Gender.from("gen", |
| 103 [["male", "\$number homme"], ["other", "\$number autre"]], null), |
| 104 ] |
| 105 ], null)), |
| 88 }; | 106 }; |
| 89 | 107 |
| 90 /** A list of the German translations that we will produce. */ | 108 /** A list of the German translations that we will produce. */ |
| 91 var german = { | 109 var german = { |
| 92 "types" : r"$a, $b, $c", | 110 "types" : r"$a, $b, $c", |
| 93 "multiLine" : "Dieser String erstreckt sich über mehrere Zeilen erstrecken.", | 111 "multiLine" : "Dieser String erstreckt sich über mehrere Zeilen erstrecken.", |
| 94 "message2" : r"Eine weitere Meldung mit dem Parameter $x", | 112 "message2" : r"Eine weitere Meldung mit dem Parameter $x", |
| 95 "alwaysTranslated" : "Diese Zeichenkette wird immer übersetzt", | 113 "alwaysTranslated" : "Diese Zeichenkette wird immer übersetzt", |
| 96 "message1" : "Dies ist eine Nachricht", | 114 "message1" : "Dies ist eine Nachricht", |
| 97 "leadingQuotes" : "\"Sogenannt\"", | 115 "leadingQuotes" : "\"Sogenannt\"", |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ["other", "\${names} gingen zum \$place"], | 148 ["other", "\${names} gingen zum \$place"], |
| 131 ], null) | 149 ], null) |
| 132 ], | 150 ], |
| 133 ["female", new Plural.from("number", | 151 ["female", new Plural.from("number", |
| 134 [ | 152 [ |
| 135 ["one", "\$names ging in dem \$place"], | 153 ["one", "\$names ging in dem \$place"], |
| 136 ["other", "\$names gingen zum \$place"], | 154 ["other", "\$names gingen zum \$place"], |
| 137 ], null) | 155 ], null) |
| 138 ] | 156 ] |
| 139 ], null | 157 ], null |
| 140 )) | 158 )), |
| 159 "outerPlural" : writer.write(new Plural.from("n", |
| 160 [ |
| 161 ['zero', 'Null'], |
| 162 ['one', 'ein'], |
| 163 ['other', 'einige'] |
| 164 ], null)), |
| 165 "outerGender" : writer.write(new Gender.from("g", |
| 166 [ |
| 167 ['male', 'Mann'], |
| 168 ['female', 'Frau'], |
| 169 ['other', 'andere'], |
| 170 ], null)), |
| 171 "nestedOuter" : writer.write (new Plural.from("number", |
| 172 [ |
| 173 ['other', new Gender.from("gen", |
| 174 [["male", "\$number Mann"], ["other", "\$number andere"]], null), |
| 175 ] |
| 176 ], null)), |
| 141 }; | 177 }; |
| 142 | 178 |
| 143 /** The output directory for translated files. */ | 179 /** The output directory for translated files. */ |
| 144 String targetDir; | 180 String targetDir; |
| 145 | 181 |
| 146 /** | 182 /** |
| 147 * Generate a translated json version from [originals] in [locale] looking | 183 * Generate a translated json version from [originals] in [locale] looking |
| 148 * up the translations in [translations]. | 184 * up the translations in [translations]. |
| 149 */ | 185 */ |
| 150 void translate(List originals, String locale, Map translations) { | 186 void translate(List originals, String locale, Map translations) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 168 parser.addOption("output-dir", defaultsTo: '.', | 204 parser.addOption("output-dir", defaultsTo: '.', |
| 169 callback: (value) => targetDir = value); | 205 callback: (value) => targetDir = value); |
| 170 parser.parse(args); | 206 parser.parse(args); |
| 171 | 207 |
| 172 var fileArgs = args.where((x) => x.contains('.json')); | 208 var fileArgs = args.where((x) => x.contains('.json')); |
| 173 | 209 |
| 174 var messages = json.parse(new File(fileArgs.first).readAsStringSync()); | 210 var messages = json.parse(new File(fileArgs.first).readAsStringSync()); |
| 175 translate(messages, "fr", french); | 211 translate(messages, "fr", french); |
| 176 translate(messages, "de_DE", german); | 212 translate(messages, "de_DE", german); |
| 177 } | 213 } |
| OLD | NEW |