diff --git a/sources/config.php b/sources/config.php index 55d32e5..d1e6524 100644 --- a/sources/config.php +++ b/sources/config.php @@ -1,3 +1,4 @@ + . */ + + // Limonade configuration function configure() { option('env', ENV_PRODUCTION); @@ -39,26 +42,37 @@ function T_($string) { // Before routing function before($route) { - /** + $lang_mapping = array( + 'fr' => 'fr_FR' + ); + + /** * * Locale * */ if (!isset($_SESSION['locale'])) { $locale = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); $_SESSION['locale'] = strtolower(substr(chop($locale[0]),0,2)); } + $lang = $_SESSION['locale']; + // Convert simple language code into full language code + if (array_key_exists($lang, $lang_mapping)) { + $lang = $lang_mapping[$lang]; + } + $lang = $lang.'.utf8'; $textdomain="localization"; - putenv('LANGUAGE='.$_SESSION['locale']); - putenv('LANG='.$_SESSION['locale']); - putenv('LC_ALL='.$_SESSION['locale']); - putenv('LC_MESSAGES='.$_SESSION['locale']); - setlocale(LC_ALL,$_SESSION['locale']); - setlocale(LC_CTYPE,$_SESSION['locale']); - $locales_dir = dirname(__FILE__).'/../i18n'; + + putenv('LANGUAGE='.$lang); + putenv('LANG='.$lang); + putenv('LC_ALL='.$lang); + putenv('LC_MESSAGES='.$lang); + setlocale(LC_ALL,$lang); + setlocale(LC_CTYPE,$lang); + $locales_dir = dirname(__FILE__).'/i18n'; bindtextdomain($textdomain,$locales_dir); bind_textdomain_codeset($textdomain, 'UTF-8'); textdomain($textdomain); // Set the $locale variable in template - set('locale', $_SESSION['locale']); + set('locale', $lang); } // After routing