Skip to content

Commit

Permalink
* [FIX] Fixed language selection issue. Related #14. Thanks to @osnet
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxsmin authored and nuxsmin committed Jun 11, 2016
1 parent 091ed71 commit 253b990
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion inc/SMD/Backend/SMD.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
72 changes: 36 additions & 36 deletions inc/SMD/Core/Language.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 253b990

Please sign in to comment.