progressRun function
Implementation
Future progressRun() async {
// validateParams(args);
final dartFiles = await getAllDartFiles();
final translations =
dartFiles.cast<File>().map(getI18nKeysFromFile).reduce((x, y) {
x.addAll(y);
return x;
});
final localizationPath = getLocalizationPath(r'pubspec.yaml');
final jsonEncodedData = readJsonFiles(localizationPath!);
final newFilesData = jsonEncodedData.map((file, content) {
final Map<String, dynamic> newContent = jsonDecode(content);
final itemsToAdd = translations.entries
.skipWhile((entry) => newContent.keys.contains(entry.key));
print('${itemsToAdd.length} items to add.');
newContent.addEntries(itemsToAdd);
return MapEntry(file, jsonEncode(newContent));
});
writeJsonFiles(newFilesData);
print('Items added successful.');
print('Replacing i18n comments');
dartFiles.cast<File>().forEach(removeI18nComments);
}