From 36d2e58a90b0f1c002327afb37e09a1a222e6658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Fri, 22 Mar 2013 14:46:19 +0100 Subject: [PATCH] // small fix for language installation --- classes/Language.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/classes/Language.php b/classes/Language.php index c54d122d0..d3edb9883 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -767,22 +767,25 @@ class LanguageCore extends ObjectModel return self::$countActiveLanguages; } - public static function downloadAndInstallLanguagePack($iso, $version) + public static function downloadAndInstallLanguagePack($iso, $version = null) { require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php'); if (!Validate::isLanguageIsoCode($iso)) return false; - + + if ($version == null) + $version = _PS_VERSION_; + $lang_pack_ok = false; $errors = array(); $file = _PS_TRANSLATIONS_DIR_.$iso.'.gzip'; - if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso)) + if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.$iso)) $errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.'); elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link)) $errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.'); - elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$version.'/'.$iso.'.gzip')) - if (!is_writable($file) || !file_put_contents($file, $content)) + elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$lang_pack->iso_code.'.gzip')) + if (!@file_put_contents($file, $content)) $errors[] = Tools::displayError('Server does not have permissions for writing.'); if (file_exists($file)) { @@ -805,6 +808,8 @@ class LanguageCore extends ObjectModel } @unlink($file); } + else + $errors[] = Tools::displayError('No language pack is available for your version.'); return count($errors) ? $errors : true; }