readTranslationApplyFromConsole method
If application is running in interactive mode this method will read and parse selected by user type of applying
Implementation
TranslationApplying readTranslationApplyFromConsole() {
final line = stdin.readLineSync(encoding: Encoding.getByName('utf-8')!);
if (line == null || line.isEmpty) {
logger.warning('Line is empty. Will discard current translation '
'${currentItem.key}');
return TranslationApplying(
TranslationApplyingType.discardAll,
);
}
final firstChar = line[0].toLowerCase();
switch (firstChar) {
case 'y':
return TranslationApplying(
TranslationApplyingType.applyAll,
);
case 'n':
return TranslationApplying(
TranslationApplyingType.discardAll,
);
case 's':
final selectedLanguagesStr = line.replaceFirst(firstChar, '').trim();
final selectedLanguages =
selectedLanguagesStr.split(',').map((x) => x.trim()).toList();
if (selectedLanguages.isEmpty) {
logger.warning('Select mode but language list is empty $line '
'${currentItem.key}');
}
return TranslationApplying(
TranslationApplyingType.selectTranslations,
selectedLanguages: selectedLanguages,
);
case 'c':
return TranslationApplying(
TranslationApplyingType.cancel,
);
default:
logger.warning('Unsupported apply mode $line');
return TranslationApplying(
TranslationApplyingType.discardAll,
);
}
}