public static $l_cache;
protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE)
{
// need to be called in order to populate $classInModule
$str = self::findTranslation('newsletterpro', $string, 'AdminNewsletterPro');
$str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str)));
}
/**
* findTranslation (initially in Module class), to make translations works
*
* @param string $name module name
* @param string $string string to translate
* @param string $source current class
* @return string translated string
*/
public static function findTranslation($name, $string, $source)
{
static $_MODULES;
if (!is_array($_MODULES))
{
// note: $_COOKIE[iso_code] is set in createCustomToken();
$file = _PS_MODULE_DIR_.'newsletterpro/translations/'.Context::getContext()->language->iso_code.'.php';
if (file_exists($file) && include($file))
$_MODULES = !empty($_MODULES)?array_merge($_MODULES, $_MODULE):$_MODULE;
}
$cache_key = $name.'|'.$string.'|'.$source;
if (!isset(self::$l_cache[$cache_key]))
{
if (!is_array($_MODULES))
return $string;
// set array key to lowercase for 1.3 compatibility
$_MODULES = array_change_key_case($_MODULES);
if (defined('_THEME_NAME_'))
$currentKey = '<{'.strtolower($name).'}'.strtolower(_THEME_NAME_).'>'.strtolower($source).'_'.md5($string);
else
$currentKey = '<{'.strtolower($name).'}default>'.strtolower($source).'_'.md5($string);
// note : we should use a variable to define the default theme (instead of "prestashop")
$defaultKey = '<{'.strtolower($name).'}prestashop>'.strtolower($source).'_'.md5($string);
$currentKey = $defaultKey;
if (isset($_MODULES[$currentKey]))
$ret = stripslashes($_MODULES[$currentKey]);
elseif (isset($_MODULES[strtolower($currentKey)]))
$ret = stripslashes($_MODULES[strtolower($currentKey)]);
elseif (isset($_MODULES[$defaultKey]))
$ret = stripslashes($_MODULES[$defaultKey]);
elseif (isset($_MODULES[strtolower($defaultKey)]))
$ret = stripslashes($_MODULES[strtolower($defaultKey)]);
else
$ret = stripslashes($string);
self::$l_cache[$cache_key] = $ret;
}
return self::$l_cache[$cache_key];
}