applyTranslation method
Replaces the translatable content while preserving its whitespace.
Implementation
String applyTranslation(String translatedText) {
final source = textToTranslate;
if (source.isEmpty) {
return text;
}
final sourceStart = text.indexOf(source);
return '${text.substring(0, sourceStart)}'
'${translatedText.trim()}'
'${text.substring(sourceStart + source.length)}';
}