mirror of
https://github.com/slawkens/myaac.git
synced 2025-12-04 16:46:50 +01:00
First public release of MyAAC
This commit is contained in:
51
install/includes/locale.php
Normal file
51
install/includes/locale.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
if(isset($_POST['lang']))
|
||||
{
|
||||
setcookie('locale', $_POST['lang']);
|
||||
$_COOKIE['locale'] = $_POST['lang'];
|
||||
}
|
||||
|
||||
if(isset($_COOKIE['locale']))
|
||||
{
|
||||
$locale_ = $_COOKIE['locale'];
|
||||
$lang_size = strlen($locale_);
|
||||
if(!$lang_size || $lang_size > 4 || !preg_match("/[a-z]/", $locale_)) // validate locale
|
||||
$_COOKIE['locale'] = "en";
|
||||
}
|
||||
else
|
||||
{
|
||||
// detect locale
|
||||
$locale_s = get_browser_languages();
|
||||
if(!sizeof($locale_s))
|
||||
$locale__ = 'en';
|
||||
else
|
||||
{
|
||||
foreach($locale_s as $id => $tmp)
|
||||
{
|
||||
$tmp_file = LOCALE . $tmp;
|
||||
if(@file_exists($tmp_file))
|
||||
{
|
||||
$locale_ = $tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($locale_))
|
||||
$locale_ = 'en';
|
||||
}
|
||||
|
||||
require(LOCALE . 'en/main.php');
|
||||
require(LOCALE . 'en/install.php');
|
||||
|
||||
$file_main = LOCALE . $locale_ . '/main.php';
|
||||
if(!file_exists($file_main))
|
||||
$file_main = LOCALE . 'en/main.php';
|
||||
|
||||
$file_install = LOCALE . $locale_ . '/install.php';
|
||||
if(!file_exists($file_install))
|
||||
$file_install = LOCALE . 'en/install.php';
|
||||
|
||||
require($file_main);
|
||||
require($file_install);
|
||||
?>
|
||||
Reference in New Issue
Block a user