//fix install bug when no internet connection
This commit is contained in:
@@ -684,7 +684,7 @@ class LanguageCore extends ObjectModel
|
||||
return Tools::generateHtaccess();
|
||||
}
|
||||
|
||||
public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false)
|
||||
public static function checkAndAddLanguage($iso_code, $lang_pack = false, $only_add = false, $params_lang = null)
|
||||
{
|
||||
if (Language::getIdByIso($iso_code))
|
||||
return true;
|
||||
@@ -703,6 +703,11 @@ class LanguageCore extends ObjectModel
|
||||
&& isset($lang_pack->iso_code))
|
||||
$lang->name = $lang_pack->name;
|
||||
}
|
||||
elseif ($params_lang !== null && is_array($params_lang))
|
||||
{
|
||||
foreach ($params_lang as $key => $value)
|
||||
$lang->$key = $value;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -770,7 +775,7 @@ class LanguageCore extends ObjectModel
|
||||
return self::$countActiveLanguages;
|
||||
}
|
||||
|
||||
public static function downloadAndInstallLanguagePack($iso, $version = null)
|
||||
public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
|
||||
{
|
||||
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
|
||||
|
||||
@@ -779,7 +784,7 @@ class LanguageCore extends ObjectModel
|
||||
|
||||
if ($version == null)
|
||||
$version = _PS_VERSION_;
|
||||
|
||||
$lang_pack = false;
|
||||
$lang_pack_ok = false;
|
||||
$errors = array();
|
||||
$file = _PS_TRANSLATIONS_DIR_.$iso.'.gzip';
|
||||
@@ -801,7 +806,7 @@ class LanguageCore extends ObjectModel
|
||||
AdminTranslationsController::checkAndAddMailsFiles($iso, $files_list);
|
||||
AdminTranslationsController::addNewTabs($iso, $files_list);
|
||||
}
|
||||
if (!Language::checkAndAddLanguage((string)$iso, $lang_pack))
|
||||
if (!Language::checkAndAddLanguage((string)$iso, $lang_pack, false, $params))
|
||||
$errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$iso;
|
||||
@unlink($file);
|
||||
}
|
||||
|
||||
@@ -306,11 +306,13 @@ class InstallModelInstall extends InstallAbstractModel
|
||||
|
||||
if (!$xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_.$iso.'/language.xml'))
|
||||
throw new PrestashopInstallerException($this->language->l('File "language.xml" not valid for language iso "%s"', $iso));
|
||||
|
||||
$params_lang = array('name' => (string)$xml->name, 'iso_code' => (string)$xml->language_code);
|
||||
|
||||
if (InstallSession::getInstance()->safe_mode)
|
||||
Language::checkAndAddLanguage($iso, false, true);
|
||||
Language::checkAndAddLanguage($iso, false, true, $params_lang);
|
||||
else
|
||||
Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_);
|
||||
Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_, $params_lang);
|
||||
|
||||
if (!$id_lang = Language::getIdByIso($iso))
|
||||
throw new PrestashopInstallerException($this->language->l('Cannot install language "%s"', ($xml->name) ? $xml->name : $iso));
|
||||
|
||||
Reference in New Issue
Block a user