removeI18nComments function
void
removeI18nComments(
)
Implementation
void removeI18nComments(File file) {
final findRegex = RegExp(r'''[\'\'](.*)[\'\'].i18n\(.*\).*\/\/(.*)''');
final replaceRegex = RegExp(r'''\/\/(.*)''');
var data = file.readAsLinesSync();
var containsUpdate = false;
var newData = data.map((line) {
if (line.contains(findRegex)) {
containsUpdate = true;
return line.replaceAll(replaceRegex, '');
} else {
return line;
}
}).toList();
if (containsUpdate) {
file.writeAsStringSync('${newData.join('\n')}\n');
print('file ${file.path} updated');
}
}