update to current dev a50c0d0b2d
This commit is contained in:
1 parent
9ada4ea601
commit
3fe5cdf55d
14 files changed
+583
-100
No files matched your search
@@ -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