Qware_core/install/check_lang.php

112 lines
2.8 KiB
PHP
Raw Normal View History

2020-12-03 16:35:44 +01:00
<?php
/**------------------------------------------------
*
* Rooty, 2018 <rooty@rooty.me>
*
*
* This software is protected by copyright, please
* read the file COPYRIGHT.
* This program is distributed in the hope that it
* will be useful, but without any warranty; without
* even the implied warranty of merchantability or
* fitness for a particular purpose. Please
* read the file LICENCE.
*
* Fichier check_lang.php
*
* Ce fichier permet la vérification de la langue de l'utilisateur lors de l'installation
*
* @author Initiance <www.initiance.com|martial@initiance.com>
* @link www.rooty.me
* @since 2018/04/02
* @version 0.3
* @package install
* @copyright Copyright &copy; 2009-2018, Rooty
* @docreview Tristan <tristan@initiance.com> | 30-10-2005
*/
/**
*
*/
function check_lang($filetest="")
{
2020-12-07 13:28:14 +01:00
global $QWARE_ROOT_PATH, $_SERVER;
2020-12-03 16:35:44 +01:00
// The order here _is_ important, at least for major_minor
// matches. Don't go moving these around without checking with
// me first - psoTFX
$match_lang = array(
'ar' => 'ar([_-][a-z]+)?',
'bg' => 'bg',
'ca' => 'ca',
'cs' => 'cs',
'da' => 'da',
'de' => 'de([_-][a-z]+)?',
'gb' => 'en([_-][a-z]+)?',
'et' => 'et',
'fi' => 'fi',
'fr' => 'fr([_-][a-z]+)?',
'el' => 'el',
'es-ar' => 'es[_-]ar',
'es' => 'es([_-][a-z]+)?',
'gd' => 'gd',
'gl' => 'gl',
'gu' => 'gu',
'he' => 'he',
'hi' => 'hi',
'hr' => 'hr',
'hu' => 'hu',
'is' => 'is',
'id' => 'id([_-][a-z]+)?',
'it' => 'it([_-][a-z]+)?',
'ja' => 'ja([_-][a-z]+)?',
'ko' => 'ko([_-][a-z]+)?',
'lv' => 'lv',
'lt' => 'lt',
'mk' => 'mk',
'nl' => 'nl([_-][a-z]+)?',
'no' => 'no',
'pa' => 'pa',
'pl' => 'pl',
'pt-br' => 'pt[_-]br',
'pt' => 'pt([_-][a-z]+)?',
'ro' => 'ro([_-][a-z]+)?',
'ru' => 'ru([_-][a-z]+)?',
'sl' => 'sl([_-][a-z]+)?',
'sq' => 'sq',
'sr' => 'sr([_-][a-z]+)?',
'sv' => 'sv([_-][a-z]+)?',
'sv' => 'sv([_-][a-z]+)?',
'th' => 'th([_-][a-z]+)?',
'tr' => 'tr([_-][a-z]+)?',
'uk' => 'uk([_-][a-z]+)?',
'ur' => 'ur',
'vi' => 'vi',
'zh-tw' => 'zh[_-]tw',
'zh' => 'zh',
'gb' => 'us',
);
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$accept_lang_array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
for ($i = 0; $i < sizeof($accept_lang_array); $i++)
{
@reset($match_lang);
while (list($lang, $match) = each($match_lang))
{
if (preg_match('#' . $match . '#i', trim($accept_lang_array[$i])))
{
2020-12-07 13:28:14 +01:00
if (file_exists(($QWARE_ROOT_PATH . 'data/message/' . strtolower($lang)."/".$filetest)))
2020-12-03 16:35:44 +01:00
{
return strtolower($lang)."/";
}
}
}
}
}
return 'FR';
}
?>