X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fpgettext.php;h=da47b8b6c13871ad4970587339f1f2be16dd2420;hb=3b4f72da939fa9f5155311799044414220d5d039;hp=79b341c0da4986b735a68b1bbeee25c7d3d04346;hpb=09851331a9dc8601919cd0c9200686b92843d235;p=friendica.git diff --git a/include/pgettext.php b/include/pgettext.php index 79b341c0da..da47b8b6c1 100644 --- a/include/pgettext.php +++ b/include/pgettext.php @@ -10,9 +10,9 @@ * */ -use \Friendica\Core\Config; +use Friendica\Core\Config; -require_once("include/dba.php"); +require_once "include/dba.php"; if (! function_exists('get_browser_language')) { /** @@ -20,7 +20,7 @@ if (! function_exists('get_browser_language')) { */ function get_browser_language() { - if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) { + if (x($_SERVER, 'HTTP_ACCEPT_LANGUAGE')) { // break up string into pieces (languages and q factors) preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); @@ -29,11 +29,11 @@ function get_browser_language() { if (count($lang_parse[1])) { // go through the list of prefered languages and add a generic language // for sub-linguas (e.g. de-ch will add de) if not already in array - for ($i=0; $i3 ) { + if (strlen($lang_parse[1][$i])>3 ) { $dashpos = strpos($lang_parse[1][$i], '-'); - if (! in_array(substr($lang_parse[1][$i], 0, $dashpos), $lang_list ) ) { + if (!in_array(substr($lang_parse[1][$i], 0, $dashpos), $lang_list ) ) { $lang_list[] = strtolower(substr($lang_parse[1][$i], 0, $dashpos)); } } @@ -42,9 +42,9 @@ function get_browser_language() { } // check if we have translations for the preferred languages and pick the 1st that has - for ($i=0; $ilangsave = $lang; - if ($language === $lang) + if ($language === $lang) { return; + } if (isset($a->strings) && count($a->strings)) { $a->stringsave = $a->strings; @@ -77,18 +78,19 @@ function push_lang($language) { function pop_lang() { global $lang, $a; - if ($lang === $a->langsave) + if ($lang === $a->langsave) { return; + } - if (isset($a->stringsave)) + if (isset($a->stringsave)) { $a->strings = $a->stringsave; - else + } else { $a->strings = array(); + } $lang = $a->langsave; } - // l if (! function_exists('load_translation_table')) { @@ -104,13 +106,11 @@ function load_translation_table($lang) { $a->strings = array(); // load enabled plugins strings - $plugins = q("SELECT name FROM addon WHERE installed=1;"); - if ($plugins!==false) { - foreach ($plugins as $p) { - $name = $p['name']; - if (file_exists("addon/$name/lang/$lang/strings.php")) { - include("addon/$name/lang/$lang/strings.php"); - } + $plugins = dba::select('addon', array('name'), array('installed' => true)); + while ($p = dba::fetch($plugins)) { + $name = $p['name']; + if (file_exists("addon/$name/lang/$lang/strings.php")) { + include("addon/$name/lang/$lang/strings.php"); } }