]> git.mxchange.org Git - friendica-addons.git/commitdiff
Use system detected language
authorSandro Santilli <strk@keybit.net>
Thu, 10 Sep 2015 07:54:26 +0000 (09:54 +0200)
committerSandro Santilli <strk@keybit.net>
Thu, 10 Sep 2015 07:54:26 +0000 (09:54 +0200)
langfilter/langfilter.php

index bbdc47fe2a9aae1bca18350692a2e4a532738128..53a7ac8ad82866fde0a67d908a67e93db602e846 100644 (file)
@@ -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))