Only once here for $lang!"; $language = BASEDIR . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $lang . '.php'; if (is_readable($language)) { if ((@require $language) !== FALSE) { // echo "
Loaded: $lang!"; self::$translations[$lang] = $translation; } else { $lang = 'default'; } } else { $lang = 'default'; } } if (empty($key)) { return ''; } if (isset(self::$translations[$lang][$key])) { // echo "
Case 1: $lang!"; return self::$translations[$lang][$key]; } if (isset(self::$translations['default'][$key])) { // echo "
Case 2: $lang!"; return self::$translations['default'][$key]; } if (isset(self::$translations['en'][$key])) { // echo "
Case 3: $lang!"; return self::$translations['en'][$key]; } // echo "
Case 4: $lang!". var_dump(self::$translations['en']) .""; return "[[$key]]"; } } /** * get the language string $key * return string */ function L($key){ global $language; if (empty($key)) { return ''; } if (isset($language[$key])) { return $language[$key]; } return "[[$key]]"; } /** * get the language string $key in $lang * or current default language if $lang * is not given. * return string */ function tL($key, $lang = null) { return FlySprayI18N::L($key, $lang); } /** * html escaped variant of the previous * return $string */ function eL($key){ return htmlspecialchars(L($key), ENT_QUOTES, 'utf-8'); } function load_translations(){ global $proj, $language, $user, $fs; # Load translations # if no valid lang_code, return english # valid == a-z and "_" case insensitive if (isset($user) && array_key_exists('lang_code', $user->infos)){ $lang_code=$user->infos['lang_code']; } # 20150211 add language preferences detection of visitors # locale_accept_from_http() not available on every hosting, so we must parse it self. # TODO ..and we can loop later through $langs until we find a matching translation file if((!isset($lang_code) || $lang_code=='' || $lang_code=='browser') && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ foreach( explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) { # taken from a php.net comment $pattern = '/^(?P