public function testCode3ToNameFail() { $this->assertNull(Text_LanguageDetect_ISO639::code3ToName('nxx')); }
function langfilter_prepare_body(&$a, &$b) { $logged_user = local_user(); if (!$logged_user) { return; } # Never filter own messages # TODO: find a better way to extract this $logged_user_profile = $a->config['system']['url'] . '/profile/' . $a->user['nickname']; if ($logged_user_profile == $b['item']['author-link']) { return; } # Don't filter if language filter is disabled if (get_pconfig($logged_user, 'langfilter', 'disable')) { return; } $spoken_config = get_pconfig(local_user(), 'langfilter', 'languages'); $minconfidence = get_pconfig(local_user(), 'langfilter', 'minconfidence'); # Don't filter if no spoken languages are configured if (!$spoken_config) { return; } $spoken_languages = explode(',', $spoken_config); # Extract the language of the post $opts = $b['item']['postopts']; if (!$opts) { return; } # no options associated to post if (!preg_match('/\\blang=([^;]*);([^:]*)/', $opts, $matches)) { return; } # no lang options associated to post $lang = $matches[1]; $confidence = $matches[2]; # Do not filter if language detection confidence is too low if ($minconfidence && $confidence < $minconfidence) { return; } $iso2 = Text_LanguageDetect_ISO639::nameToCode2($lang); if (!$iso2) { return; } $spoken = in_array($iso2, $spoken_languages); if (!$spoken) { $rnd = random_string(8); $b['html'] = '<div id="langfilter-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'langfilter-' . $rnd . '\'); >' . sprintf(t('unspoken language %s - Click to open/close'), $lang) . '</div><div id="langfilter-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>'; } }
function langfilter_prepare_body(&$a, &$b) { if (get_pconfig(local_user(), 'langfilter', 'disable')) { return; } # Never filter own messages # TODO: find a better way to extract this $logged_user_profile = $a->config['system']['url'] . '/profile/' . $a->user['nickname']; if ($logged_user_profile == $b['item']['author-link']) { return; } if (local_user()) { $langs = get_pconfig(local_user(), 'langfilter', 'languages'); } if ($langs) { $arr = explode(',', $langs); } else { return; } $found = false; $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)) { $found = true; } if ($lng == null) { $found = false; } if ($found) { $rnd = random_string(8); $b['html'] = '<div id="langfilter-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'langfilter-' . $rnd . '\'); >' . sprintf(t('unspoken language %s - Click to open/close'), $lang) . '</div><div id="langfilter-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>'; } }