2023-08-29 16:11:51 +00:00
|
|
|
import 'utils/translation/arb_file_utils.dart';
|
|
|
|
import 'utils/translation/translation_constants.dart';
|
|
|
|
import 'utils/translation/translation_utils.dart';
|
2023-08-24 13:54:05 +00:00
|
|
|
|
2024-11-25 14:08:30 +00:00
|
|
|
/// dart run tool/append_translation.dart "hello_world" "Hello World!"
|
2024-07-21 00:46:43 +00:00
|
|
|
|
2023-08-24 13:54:05 +00:00
|
|
|
void main(List<String> args) async {
|
2024-09-26 01:51:38 +00:00
|
|
|
if (args.length < 2) {
|
2023-08-24 13:54:05 +00:00
|
|
|
throw Exception(
|
2024-09-26 01:51:38 +00:00
|
|
|
'Insufficient arguments!\n\nTry to run `./append_translation.dart "greetings" "Hello World!"`');
|
2023-08-24 13:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final name = args.first;
|
2024-09-26 01:51:38 +00:00
|
|
|
final text = args[1];
|
|
|
|
final force = args.last == "--force";
|
2023-08-24 13:54:05 +00:00
|
|
|
|
|
|
|
print('Appending "$name": "$text"');
|
|
|
|
|
2024-02-06 20:12:51 +00:00
|
|
|
// add translation to all languages:
|
2023-08-24 13:54:05 +00:00
|
|
|
for (var lang in langs) {
|
2023-08-29 16:11:51 +00:00
|
|
|
final fileName = getArbFileName(lang);
|
2023-08-24 13:54:05 +00:00
|
|
|
final translation = await getTranslation(text, lang);
|
|
|
|
|
2024-09-26 01:51:38 +00:00
|
|
|
appendStringToArbFile(fileName, name, translation, force: force);
|
2023-08-24 13:54:05 +00:00
|
|
|
}
|
2024-02-06 20:12:51 +00:00
|
|
|
|
|
|
|
print('Alphabetizing all files...');
|
|
|
|
|
|
|
|
for (var lang in langs) {
|
|
|
|
final fileName = getArbFileName(lang);
|
|
|
|
alphabetizeArbFile(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
print('Done!');
|
2023-10-05 01:09:07 +00:00
|
|
|
}
|