From 1212ef51f7f09cd41f849c50205c9cf5ed90049e Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 23 Oct 2017 20:02:39 +0000 Subject: [PATCH] Added constants for locales --- includes/locale.php | 38 ++++++++++++++++++-------------------- index.php | 4 ++++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/includes/locale.php b/includes/locale.php index af6f6c18..a123b17a 100755 --- a/includes/locale.php +++ b/includes/locale.php @@ -6,21 +6,21 @@ */ if (!isset($_SESSION["locale"])) { - $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); - switch ($lang){ - case "de": - $locale = "de_DE.UTF-8"; - break; - case "fr": - $locale = "fr_FR.UTF-8"; - break; - case "it": - $locale = "it_IT.UTF-8"; - break; - default: - $locale = "en_US.UTF-8"; - break; - } + $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); + switch ($lang){ + case "de": + $locale = "de_DE.UTF-8"; + break; + case "fr": + $locale = "fr_FR.UTF-8"; + break; + case "it": + $locale = "it_IT.UTF-8"; + break; + default: + $locale = "en_US.UTF-8"; + break; + } } // debug @@ -30,10 +30,8 @@ $_SESSION["locale"] = $locale; putenv("LANG=" . $_SESSION["locale"]); setlocale(LC_ALL, $_SESSION["locale"]); -$domain = "messages"; -$locale_root = "locale"; -bindtextdomain($domain, $locale_root); -bind_textdomain_codeset($domain, 'UTF-8'); +bindtextdomain(LOCALE_DOMAIN, LOCALE_ROOT); +bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8'); -textdomain($domain); +textdomain(LOCALE_DOMAIN); ?> diff --git a/index.php b/index.php index 1665dfbf..fcecd06f 100755 --- a/index.php +++ b/index.php @@ -43,6 +43,10 @@ define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc'); define('RASPI_OPENVPN_ENABLED', false ); define('RASPI_TORPROXY_ENABLED', false ); +// Locale settings +define('LOCALE_ROOT', 'locale'); +define('LOCALE_DOMAIN', 'messages'); + include_once( RASPI_CONFIG.'/raspap.php' ); include_once( 'includes/locale.php'); include_once( 'includes/functions.php' );