2023-08-29 16:11:51 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2024-12-09 18:23:59 +00:00
|
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
void main(List<String> args) async {
|
2024-12-09 18:23:59 +00:00
|
|
|
printV('Checking Consistency of all arb-files. Default: $defaultLang');
|
2023-08-29 16:11:51 +00:00
|
|
|
|
|
|
|
final doFix = args.contains("--fix");
|
|
|
|
|
|
|
|
if (doFix)
|
2024-12-09 18:23:59 +00:00
|
|
|
printV('Auto fixing enabled!\n');
|
2023-08-29 16:11:51 +00:00
|
|
|
else
|
2024-12-09 18:23:59 +00:00
|
|
|
printV('Auto fixing disabled!\nRun with arg "--fix" to enable autofix\n');
|
2023-08-29 16:11:51 +00:00
|
|
|
|
|
|
|
final fileName = getArbFileName(defaultLang);
|
|
|
|
final file = File(fileName);
|
|
|
|
final arbObj = readArbFile(file);
|
|
|
|
|
|
|
|
for (var lang in langs) {
|
|
|
|
final fileName = getArbFileName(lang);
|
|
|
|
final missingKeys = getMissingKeysInArbFile(fileName, arbObj.keys);
|
|
|
|
if (missingKeys.isNotEmpty) {
|
|
|
|
final missingDefaults = <String, String>{};
|
|
|
|
|
|
|
|
missingKeys.forEach((key) {
|
2024-12-09 18:23:59 +00:00
|
|
|
printV('Missing in "$lang": "$key"');
|
2023-08-29 16:11:51 +00:00
|
|
|
if (doFix)
|
|
|
|
missingDefaults[key] = arbObj[key] as String;
|
|
|
|
});
|
|
|
|
|
2024-02-06 20:44:21 +00:00
|
|
|
if (missingDefaults.isNotEmpty) {
|
2023-08-29 16:11:51 +00:00
|
|
|
await appendTranslations(lang, missingDefaults);
|
2024-02-06 20:44:21 +00:00
|
|
|
alphabetizeArbFile(fileName);
|
|
|
|
}
|
2023-08-29 16:11:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|