indesign47 Posted May 22, 2013 Share Posted May 22, 2013 (edited) Hello, I have develop a module that override AdminImportController.php (1.5.4.1) Module-> override-> controllers -> admin-> AdminImportController.php Works fine execpt the translation of fields of AdminImportController.php Fields of files tpl (View et Form) are working good. Translation are save correctly in the file of translation fr.php but in the Form and in the View fields of AdminImportController.php are not translated into French ! File AdminImportController.php $this->available_fields = array( 'link' => array('label' => $this->l('Link')), ); File fr.php global $_MODULE; $_MODULE = array(); $_MODULE['<{importx}prestashop>adminimportcontroller_97e7c9a7d06eac006a28bf05467fcc8b'] = 'Lien'; I try to find a solution in AdminTranslationsController.php and translate.php but with no success. Does anyone have a solution ? Thanks Edit : SOLVED Edited June 15, 2013 by indesign (see edit history) Link to comment Share on other sites More sharing options...
indesign47 Posted May 28, 2013 Author Share Posted May 28, 2013 Does anyone have already translate field of a override controller by a module ? Link to comment Share on other sites More sharing options...
Valérie Assetskaya Posted June 10, 2013 Share Posted June 10, 2013 Hi, The translation is usually made in the backend and it doesn't matter if there was an override. Please, view our article -http://blog.belvg.com/developer-tips-translations-for-module-custom-scripts.html Best regards. Link to comment Share on other sites More sharing options...
indesign47 Posted June 10, 2013 Author Share Posted June 10, 2013 Hi Valérie, First, thanks for you answer The translation is usually made in the backend and it doesn't matter if there was an override Not sure understand what you mean exactly. (maybe because I am french ) My module should bring all the translation (TPL, PHP) with the files > translation > fr.php or it.fr It's right ? I have a quiet look at your link, I should test it. Does it works with 1.5.4 ? Best regards. Link to comment Share on other sites More sharing options...
Valérie Assetskaya Posted June 14, 2013 Share Posted June 14, 2013 Hi, Yes, you are right. The modules should be translated via Back End, then the files will be automatically created. Best regards. Link to comment Share on other sites More sharing options...
indesign47 Posted June 15, 2013 Author Share Posted June 15, 2013 Hi Valérie, Find the solution Change nom_du_module with your name of module Change AdminImportController with your name of controller public static $l_cache; protected function l($string, $class = 'AdminTab', $addslashes = FALSE, $htmlentities = TRUE) { // need to be called in order to populate $classInModule $str = self::findTranslation('nom_du_module', $string, 'AdminImportController'); $str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str; return str_replace('"', '"', ($addslashes ? addslashes($str) : stripslashes($str))); } /** * findTranslation (initially in Module class), to make translations works * * @param string $name module name * @param string $string string to translate * @param string $source current class * @return string translated string */ public static function findTranslation($name, $string, $source) { static $_MODULES; if (!is_array($_MODULES)) { // note: $_COOKIE[iso_code] is set in createCustomToken(); $file = _PS_MODULE_DIR_.'nom_du_module/translations/'.Context::getContext()->language->iso_code.'.php'; if (file_exists($file) && include($file)) $_MODULES = !empty($_MODULES)?array_merge($_MODULES, $_MODULE):$_MODULE; } $cache_key = $name.'|'.$string.'|'.$source; if (!isset(self::$l_cache[$cache_key])) { if (!is_array($_MODULES)) return $string; // set array key to lowercase for 1.3 compatibility $_MODULES = array_change_key_case($_MODULES); if (defined('_THEME_NAME_')) $currentKey = '<{'.strtolower($name).'}'.strtolower(_THEME_NAME_).'>'.strtolower($source).'_'.md5($string); else $currentKey = '<{'.strtolower($name).'}default>'.strtolower($source).'_'.md5($string); // note : we should use a variable to define the default theme (instead of "prestashop") $defaultKey = '<{'.strtolower($name).'}prestashop>'.strtolower($source).'_'.md5($string); $currentKey = $defaultKey; if (isset($_MODULES[$currentKey])) $ret = stripslashes($_MODULES[$currentKey]); elseif (isset($_MODULES[strtolower($currentKey)])) $ret = stripslashes($_MODULES[strtolower($currentKey)]); elseif (isset($_MODULES[$defaultKey])) $ret = stripslashes($_MODULES[$defaultKey]); elseif (isset($_MODULES[strtolower($defaultKey)])) $ret = stripslashes($_MODULES[strtolower($defaultKey)]); else $ret = stripslashes($string); self::$l_cache[$cache_key] = $ret; } return self::$l_cache[$cache_key]; } Thanks for your participation Link to comment Share on other sites More sharing options...
Adam40 Posted November 13, 2017 Share Posted November 13, 2017 (edited) I would like to get my Page Title for search site from SEO & URLs Preferences and add to end my search word. For example on title search site I would like to have: " Your results for iPhone" What doing this? You have any ideas for this? Edited November 30, 2017 by Adam40 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now