stdoutCurrentChange method
void
stdoutCurrentChange()
Prints current item changes to console
Implementation
void stdoutCurrentChange() {
final currentTranslations = _getCurrentTranslations();
final allUnmodified = currentTranslations.entries
.where((x) => x.value != null)
.all((x) =>
x.value!.modificationType == ARBItemModificationType.unmodified);
if (currentTranslations.isEmpty || allUnmodified) {
return;
}
const divider =
'==============================================================';
const green = '32';
const yellow = '33';
const blue = '34';
final msg = StringBuffer();
void startColor(String color) => msg.write('\x1B[${color}m');
void endColor() => msg.write('\x1B[0m');
msg.writeln(divider);
msg.writeln(currentItem.key);
msg.writeln('[$originalLocale] [SRC]: "${currentItem.value}"');
for (final kv in currentTranslations.entries) {
final lang = kv.key;
final translation = kv.value;
if (translation == null) {
continue;
}
msg.write('[$lang]');
msg.write(' ');
final modificationType = translation.modificationType;
final modificationTypeStr = _formatModificationType(
modificationType,
);
msg.write('[$modificationTypeStr]');
msg.write(': ');
switch (modificationType) {
case ARBItemModificationType.unmodified:
startColor(blue);
msg.write('"${translation.value}"');
endColor();
break;
case ARBItemModificationType.edited:
startColor(yellow);
msg.write('"${translation.originalValue!}"');
msg.write(' -> ');
msg.write('"${translation.value}"');
endColor();
break;
case ARBItemModificationType.added:
startColor(green);
msg.write('"${translation.value}"');
endColor();
}
msg.writeln();
}
stdout.writeln(msg.toString());
}