Tuni-Soft Posted May 17, 2013 Share Posted May 17, 2013 Hello For translation i use $this->l($str) but this returns the translated string for the current language. I'm looking for a way to get the translated string per language i.e. get the translation of a given string in all available languages. I inspected the class in translate.php but came out with no solution! any help is much appreciated Thank you Link to comment Share on other sites More sharing options...
vekia Posted May 17, 2013 Share Posted May 17, 2013 You want to display: $this->l($str) in all available languages? Am I right? If so, this isn't possible by default. Link to comment Share on other sites More sharing options...
Tuni-Soft Posted May 18, 2013 Author Share Posted May 18, 2013 Thank you, i finally figured it out this function can be included in your module /** * Return the translation for a string given a language iso code 'en' 'fr' .. * * @public * @param $string string to translate * @param $iso_lang language iso code * @param $source source file without extension * @param $js if it's inside a js string * @return string translation */ public function _translate($string,$iso_lang,$source,$js=false){ $file = dirname(__FILE__).'/translations/'.$iso_lang.'.php'; if(!file_exists($file)) return $string; include($file); $key = md5(str_replace('\'', '\\\'', $string)); $current_key = strtolower('<{'.$this->name.'}'._THEME_NAME_.'>'.$source).'_'.$key; $default_key = strtolower('<{'.$this->name.'}prestashop>'.$source).'_'.$key; $ret = $string; if (isset($_MODULE[$current_key])) $ret = stripslashes($_MODULE[$current_key]); elseif (isset($_MODULE[$default_key])) $ret = stripslashes($_MODULE[$default_key]); if ($js) $ret = addslashes($ret); return $ret; } 1 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