// Modules translations loading fixed #PSCFV-3559

This commit is contained in:
dMetzger
2012-08-17 14:48:01 +00:00
parent 14eebbc6c4
commit 12be9fb218
+17 -28
View File
@@ -125,38 +125,27 @@ class TranslateCore
// $translations_merged is a cache of wether a specific module's translations have already been added to $_MODULES // $translations_merged is a cache of wether a specific module's translations have already been added to $_MODULES
static $translations_merged = array(); static $translations_merged = array();
if ($module instanceof Module) $name = $module instanceof Module ? $module->name : $module;
$name = $module->name;
else
$name = $module;
$local_path = _PS_MODULE_DIR_.$name.'/';
if (!isset($translations_merged[$name])) if (!isset($translations_merged[$name]))
{ {
// Check if translations exists in a current theme $filesByPriority = array(
if (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$name.'/translations/'.Context::getContext()->language->iso_code.'.php')) // Translations in theme
$file_theme = _PS_THEME_DIR_.'modules/'.$name.'/translations/'.Context::getContext()->language->iso_code.'.php'; _PS_THEME_DIR_.'modules/'.$name.'/translations/'.Context::getContext()->language->iso_code.'.php',
elseif (Tools::file_exists_cache(_PS_THEME_DIR_.'modules/'.$name.'/'.Context::getContext()->language->iso_code.'.php')) _PS_THEME_DIR_.'modules/'.$name.'/'.Context::getContext()->language->iso_code.'.php',
$file_theme = _PS_THEME_DIR_.'modules/'.$name.'/'.Context::getContext()->language->iso_code.'.php'; // PrestaShop 1.5 translations
else _PS_MODULE_DIR_.$name.'/translations/'.Context::getContext()->language->iso_code.'.php',
$file_theme = false; // PrestaShop 1.4 translations
_PS_MODULE_DIR_.$name.'/'.Context::getContext()->language->iso_code.'.php'
);
if ($file_theme && !isset($translations_merged[$name]) && Tools::file_exists_cache($file_theme) && include_once($file_theme)) foreach ($filesByPriority as $file)
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE; if (Tools::file_exists_cache($file))
else {
{ include_once($file);
// @retrocompatibility with translations files in module root
// @since 1.5 modules have a translations/ folder
if (Tools::file_exists_cache($local_path.'/translations/'.Context::getContext()->language->iso_code.'.php'))
$file = $local_path.'/translations/'.Context::getContext()->language->iso_code.'.php';
else
$file = $local_path.'/'.Context::getContext()->language->iso_code.'.php';
// Load translations file if it has not been already done
if (Tools::file_exists_cache($file) && include_once($file))
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE; $_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
} $translations_merged[$name] = true;
$translations_merged[$name] = true; break;
}
} }
$key = md5(str_replace('\'', '\\\'', $string)); $key = md5(str_replace('\'', '\\\'', $string));