function qtranxf_match_language_locale($locale) { global $q_config; foreach ($q_config['enabled_languages'] as $lang) { if (qtranxf_html_locale($q_config['locale'][$lang]) == $locale) { return $lang; } if ($q_config['locale'][$lang] == $locale) { return $lang; } if (!empty($q_config['locale_html'][$lang]) && $q_config['locale_html'][$lang] == $locale) { return $lang; } } $locale_code = substr($locale, 0, 2); foreach ($q_config['enabled_languages'] as $lang) { if ($locale_code == $lang) { return $lang; } } }
function qtranxf_http_negotiate_language() { global $q_config; if (function_exists('http_negotiate_language')) { $default_language = $q_config['default_language']; $supported = array(); $supported[] = qtranxf_html_locale($q_config['locale'][$default_language]); //needs to be the first if (!empty($q_config['locale_html'][$default_language])) { $supported[] = $q_config['locale_html'][$default_language]; } foreach ($q_config['enabled_languages'] as $lang) { if ($lang == $default_language) { continue; } $supported[] = qtranxf_html_locale($q_config['locale'][$lang]); if (!empty($q_config['locale_html'][$lang])) { $supported[] = $q_config['locale_html'][$lang]; } } $fallback = array(); $locale_negotiated = http_negotiate_language($supported, $fallback); if ($fallback == NULL) { $locale_negotiated = 'en'; } return qtranxf_match_language_locale($locale_negotiated); } else { return qtranxf_get_browser_language(); } }