Use system detected language

pull/300/head
Sandro Santilli 2015-09-10 09:54:26 +02:00
parent 5b2c4dfed9
commit 2e6abb55ea
1 changed files with 9 additions and 5 deletions

View File

@ -93,11 +93,15 @@ function langfilter_prepare_body(&$a,&$b) {
} }
$found = false; $found = false;
$l = new Text_LanguageDetect;
$l->_name_mode = 2; // two letter codes $opts = $b['item']['postopts'];
$l->_threshold = 600; // make it a bit harder to be confident with a lng if ( $opts ) {
// IOW make it more possible that lng is correct if ( preg_match('/^lang=([^;]*)/', $opts, $matches ) )
$lng = $l->detectSimple($b['html']); {
$lang = $matches[1];
$lng = Text_LanguageDetect_ISO639::nameToCode2($lang);
}
}
if ($lng==null) if ($lng==null)
return; return;
if (! in_array($lng, $arr)) if (! in_array($lng, $arr))