diff --git a/CHANGELOG b/CHANGELOG index 63a61c4..d0d204e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,7 +8,8 @@ * [FIX] Fixed config saving when no backends are defined. * [FIX] Fixed language detection when no config is set. -* [FIX] Fixed PHP version comparison * [MOD] Improved error handling when retrieving events from remote backends. +* [FIX] Fixed PHP version comparison +* [MOD] Improved error handling when retrieving events from remote backends. * [FIX] Fixed PHP version comparison * [MOD] Improved error handling when retrieving events from remote backends. diff --git a/inc/SMD/Backend/SMD.class.php b/inc/SMD/Backend/SMD.class.php index 31f054d..d7642e0 100644 --- a/inc/SMD/Backend/SMD.class.php +++ b/inc/SMD/Backend/SMD.class.php @@ -27,7 +27,6 @@ use SMD\Api\Api; use SMD\Core\ConfigBackendSMD; use SMD\Core\Exceptions\BackendException; -use SMD\Core\Exceptions\CurlException; use SMD\Core\Language; use SMD\Util\Util; diff --git a/inc/SMD/Core/Language.class.php b/inc/SMD/Core/Language.class.php index 4d1905b..6c0cff1 100644 --- a/inc/SMD/Core/Language.class.php +++ b/inc/SMD/Core/Language.class.php @@ -45,35 +45,6 @@ public static function t($string) return (self::$_lang === 'es_ES') ? $string : self::getTranslation($string); } - /** - * Obtener la traducción desde la sesión o el archivo de idioma - * - * @param $string - * @return mixed - */ - private static function getTranslation($string) - { - $sessionLang = Session::getLanguage(); - - if ($sessionLang === false - && self::checkLangFile(self::$_lang) - ) { - include_once self::getLangFile(self::$_lang); - - if (isset($LANG) - && is_array($LANG) - ) { - Session::setLanguage($LANG); - - return (isset($LANG[$string])) ? $LANG[$string] : $string; - } - - return $string; - } - - return (isset($sessionLang[$string])) ? $sessionLang[$string] : $string; - } - /** * Establece el lenguaje de la aplicación. * Esta función establece el lenguaje según esté definido en la configuración o en el navegador. @@ -85,15 +56,15 @@ private static function getGlobalLang() // Establecer a es_ES si no existe la traducción o no está establecido el lenguaje if (!empty($language) - && ((preg_match('/^es_.*/i', $browserLang) - || !self::checkLangFile($browserLang))) + && (self::checkLangFile($language) + || $language = 'es_ES') ) { - $lang = 'es_ES'; - } else { - $lang = $browserLang; + return $language; + } elseif (preg_match('/^es_.*/i', $browserLang)) { + return 'es_ES'; + } elseif (self::checkLangFile($browserLang)) { + return $browserLang; } - - return $lang; } /** @@ -127,4 +98,33 @@ private static function getLangFile($lang) { return LOCALES_PATH . DIRECTORY_SEPARATOR . "$lang.inc"; } + + /** + * Obtener la traducción desde la sesión o el archivo de idioma + * + * @param $string + * @return mixed + */ + private static function getTranslation($string) + { + $sessionLang = Session::getLanguage(); + + if ($sessionLang === false + && self::checkLangFile(self::$_lang) + ) { + include_once self::getLangFile(self::$_lang); + + if (isset($LANG) + && is_array($LANG) + ) { + Session::setLanguage($LANG); + + return (isset($LANG[$string])) ? $LANG[$string] : $string; + } + + return $string; + } + + return (isset($sessionLang[$string])) ? $sessionLang[$string] : $string; + } } \ No newline at end of file