mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-16 23:54:28 +10:00
update to current dev a50c0d0b2d
This commit is contained in:
@@ -388,7 +388,9 @@ class TranslationService extends ChangeNotifier {
|
||||
if (targetLanguageCode == null || !_isPlainTextEligible(text)) {
|
||||
return null;
|
||||
}
|
||||
final detectedLanguageCode = await detectLanguage(text);
|
||||
final detectedLanguageCode = await detectLanguage(
|
||||
_stripReplyInfoForDetection(text),
|
||||
);
|
||||
if (detectedLanguageCode != null &&
|
||||
detectedLanguageCode == targetLanguageCode) {
|
||||
return const TranslationResult(
|
||||
@@ -429,7 +431,9 @@ class TranslationService extends ChangeNotifier {
|
||||
if (targetLanguageCode == null || !_isPlainTextEligible(text)) {
|
||||
return null;
|
||||
}
|
||||
final detectedLanguageCode = await detectLanguage(text);
|
||||
final detectedLanguageCode = await detectLanguage(
|
||||
_stripReplyInfoForDetection(text),
|
||||
);
|
||||
if (detectedLanguageCode != null &&
|
||||
detectedLanguageCode == targetLanguageCode) {
|
||||
return const TranslationResult(
|
||||
@@ -470,6 +474,14 @@ class TranslationService extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
String _stripReplyInfoForDetection(String text) {
|
||||
final match = RegExp(
|
||||
r'@\[([^\]]+)\]\s+(.+)$',
|
||||
dotAll: true,
|
||||
).firstMatch(text);
|
||||
return match?.group(2) ?? text;
|
||||
}
|
||||
|
||||
Future<String?> _translateText({
|
||||
required String text,
|
||||
required String targetLanguageCode,
|
||||
|
||||
Reference in New Issue
Block a user