From cbbebcd20ced5874b97452babbffdbc6d2278d58 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:26:32 +0200 Subject: [PATCH] optimization: if gettext.so is loaded, we don`t need the fallback implementation --- inc/functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 7ed3af5a..76b1d9a8 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -19,7 +19,9 @@ require_once 'inc/database.php'; require_once 'inc/events.php'; require_once 'inc/api.php'; require_once 'inc/bans.php'; -require_once 'inc/lib/gettext/gettext.inc'; +if (!extension_loaded('gettext')) { + require_once 'inc/lib/gettext/gettext.inc'; +} // the user is not currently logged in as a moderator $mod = false; @@ -29,14 +31,17 @@ mb_internal_encoding('UTF-8'); loadConfig(); function init_locale($locale, $error='error') { - if (_setlocale(LC_ALL, $locale) === false) { - $error('The specified locale (' . $locale . ') does not exist on your platform!'); - } if (extension_loaded('gettext')) { + if (setlocale(LC_ALL, $locale) === false) { + $error('The specified locale (' . $locale . ') does not exist on your platform!'); + } bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); textdomain('tinyboard'); } else { + if (_setlocale(LC_ALL, $locale) === false) { + $error('The specified locale (' . $locale . ') does not exist on your platform!'); + } _bindtextdomain('tinyboard', './inc/locale'); _bind_textdomain_codeset('tinyboard', 'UTF-8'); _textdomain('tinyboard');