toTranslit method
Method for converting to translit for the source
value
Implementation
String toTranslit({required String source}) {
if (source.isEmpty) return source;
final regExp = RegExp(
'([а-я]+)',
caseSensitive: false,
multiLine: true,
);
if (!regExp.hasMatch(source)) return source;
final translit = <String>[];
final sourceSymbols = <String>[...source.split('')];
_transliteratedSymbol.addAll(_complicatedSymbols);
for (final element in sourceSymbols) {
final transElement = _transliteratedSymbol.containsKey(element)
? _transliteratedSymbol[element] ?? ''
: element;
translit.add(transElement);
}
return translit.join();
}