From f7bdbc138e053de3fed4eec2f427458ca3266ff3 Mon Sep 17 00:00:00 2001 From: TangMo Date: Thu, 29 Dec 2022 23:05:02 +0000 Subject: [PATCH] Adjust language detection regex --- src/Commands/GenericmessageCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/GenericmessageCommand.php b/src/Commands/GenericmessageCommand.php index 78b1a0c..e08a4e8 100644 --- a/src/Commands/GenericmessageCommand.php +++ b/src/Commands/GenericmessageCommand.php @@ -65,7 +65,7 @@ class GenericmessageCommand extends SystemCommand } $text_chara_count = count(preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY)); - $text_english_count = count(preg_split('~[^a-z]*~i', $text, 0, PREG_SPLIT_NO_EMPTY)); + $text_english_count = count(preg_split('~[^a-z 0-9\'\",.]*~i', $text, 0, PREG_SPLIT_NO_EMPTY)); if ($text_english_count >= ($text_chara_count*2 /3)) { $sourceLang = 'en'; $targetLang = 'zh';