context = Context::getContext(); } public function l($string, $source = null) { return Translate::getModuleTranslation('ets_reviews', $string, $source !== null ? $source : pathinfo(__FILE__, PATHINFO_FILENAME)); } public function display($template, $assigns = []) { if ($assigns) { $this->context->smarty->assign($assigns); } return $this->context->smarty->fetch(dirname(__FILE__) . '/../views/templates/hook/' . $template); } public static function trans($text, $iso_code, $specific = null) { if (is_array($text) || trim($text) == '' || $iso_code == '' || !Validate::isLangIsoCode($iso_code)) { return $text; } $files_by_priority = _PS_MODULE_DIR_ . 'ets_reviews/translations/' . $iso_code . '.php'; if (!@file_exists($files_by_priority)) { return $text; } $string = preg_replace("/\\\*'/", "\'", $text); $key = md5($string); $default_key = Tools::strtolower('<{ets_reviews}prestashop>' . ($specific ? Tools::strtolower($specific) : 'ets_reviews')) . '_' . $key; preg_match('/(\$_MODULE\[\'' . preg_quote($default_key) . '\'\]\s*=\s*\')(.*)(\';)/', Tools::file_get_contents($files_by_priority), $matches); if ($matches && isset($matches[2])) { return $matches[2]; } return $text; } }