From 2e6abb55ea454643e05f12e1ceaa23bb8686ae0e Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 10 Sep 2015 09:54:26 +0200 Subject: [PATCH 1/2] Use system detected language --- langfilter/langfilter.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index bbdc47fe2..53a7ac8ad 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -93,11 +93,15 @@ function langfilter_prepare_body(&$a,&$b) { } $found = false; - $l = new Text_LanguageDetect; - $l->_name_mode = 2; // two letter codes - $l->_threshold = 600; // make it a bit harder to be confident with a lng - // IOW make it more possible that lng is correct - $lng = $l->detectSimple($b['html']); + + $opts = $b['item']['postopts']; + if ( $opts ) { + if ( preg_match('/^lang=([^;]*)/', $opts, $matches ) ) + { + $lang = $matches[1]; + $lng = Text_LanguageDetect_ISO639::nameToCode2($lang); + } + } if ($lng==null) return; if (! in_array($lng, $arr)) From aee6db7b0a126ec89dd2685e524ee7853e265e44 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 10 Sep 2015 10:00:21 +0200 Subject: [PATCH 2/2] Use expanded language name, easier to read for humans --- langfilter/langfilter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index 53a7ac8ad..f7ccd0a6d 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -111,7 +111,7 @@ function langfilter_prepare_body(&$a,&$b) { if($found) { $rnd = random_string(8); - $b['html'] = ''; + $b['html'] = ''; } } ?>