kirubanidhi
kirubanidhi

Reputation: 77

Prestashop: Call to undefined method Language::updateModulesTranslations()

When installing in my custom module(for example sample module name) that time occur below this fatal error. How to resolve this error Anyone help me.

Fatal error: Call to undefined method Language::updateModulesTranslations() in /var/www/html/sf_prestashop/shop/classes/module/Module.php on line 292

Upvotes: 1

Views: 2009

Answers (1)

Knowband Plugins
Knowband Plugins

Reputation: 1317

Please check the Language class in /classes/Language.php, there must be a function named 'updateModulesTranslations', if there is not then please add the following function inside the Language class:

public static function updateModulesTranslations(Array $modules_list)
    {
        require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');

        $languages = Language::getLanguages(false);
        foreach ($languages as $lang) {
            $gz = false;
            $files_listing = array();
            foreach ($modules_list as $module_name) {
                $filegz = _PS_TRANSLATIONS_DIR_.$lang['iso_code'].'.gzip';

                clearstatcache();
                if (@filemtime($filegz) < (time() - (24 * 3600))) {
                    if (Language::downloadAndInstallLanguagePack($lang['iso_code'], null, null, false) !== true) {
                        break;
                    }
                }

                $gz = new Archive_Tar($filegz, true);
                $files_list = Language::getLanguagePackListContent($lang['iso_code'], $gz);
                foreach ($files_list as $i => $file) {
                    if (strpos($file['filename'], 'modules/'.$module_name.'/') !== 0) {
                        unset($files_list[$i]);
                    }
                }

                foreach ($files_list as $file) {
                    if (isset($file['filename']) && is_string($file['filename'])) {
                        $files_listing[] = $file['filename'];
                    }
                }
            }
            if ($gz) {
                $gz->extractList($files_listing, _PS_TRANSLATIONS_DIR_.'../', '');
            }
        }
    }

Upvotes: 2

Related Questions