| 1 | import 'print_verbose_dummy.dart'; |
| 2 | import 'utils/translation/arb_file_utils.dart'; |
| 3 | import 'utils/translation/translation_constants.dart'; |
| 4 | import 'utils/translation/translation_utils.dart'; |
| 5 | |
| 6 | /// dart run tool/append_translation.dart "hello_world" "Hello World!" |
| 7 | |
| 8 | void main(List<String> args) async { |
| 9 | if (args.length < 2) { |
| 10 | throw Exception( |
| 11 | 'Insufficient arguments!\n\nTry to run `./append_translation.dart "greetings" "Hello World!"`'); |
| 12 | } |
| 13 | |
| 14 | final name = args.first; |
| 15 | final text = args[1]; |
| 16 | final force = args.last == "--force"; |
| 17 | |
| 18 | print('Appending "$name": "$text"'); |
| 19 | |
| 20 | // add translation to all languages: |
| 21 | for (var lang in langs) { |
| 22 | final fileName = getArbFileName(lang); |
| 23 | final translation = await getTranslation(text, lang); |
| 24 | |
| 25 | appendStringToArbFile(fileName, name, translation, force: force); |
| 26 | } |
| 27 | |
| 28 | print('Alphabetizing all files...'); |
| 29 | |
| 30 | for (var lang in langs) { |
| 31 | final fileName = getArbFileName(lang); |
| 32 | alphabetizeArbFile(fileName); |
| 33 | } |
| 34 | |
| 35 | print('Done!'); |
| 36 | } |