roger@gagaphone.com Posted October 23, 2012 Share Posted October 23, 2012 I found on my server that the language tags have to be all lowercase for this to work. This may be the case for all Windows servers. 0 Quote Link to comment Share on other sites More sharing options...
jeebeezebee Posted November 26, 2012 Share Posted November 26, 2012 Up ! Some news about multiligual products ? 0 Quote Link to comment Share on other sites More sharing options...
nanghost Posted February 19, 2013 Share Posted February 19, 2013 Hi Guys, I'm using ServWise module. <english>Text here</english><spanish>Texto aquí</spanish> and work very well and no problem with it. Now, how I can change or make this work on emails and invoices? Also, the admin console, in the products and services, look like a scramble place. How I can get this to work as well? Thanks in advance, 0 Quote Link to comment Share on other sites More sharing options...
Sylvie Posted February 19, 2013 Share Posted February 19, 2013 Hi ServWise where I put that code : {getlang data=$product.name lang=$language} {getlang data=$product.description lang=$language} <English>English content</English><French>French content</French Thank YOu 0 Quote Link to comment Share on other sites More sharing options...
david.stone Posted October 2, 2013 Share Posted October 2, 2013 The solution posted for me didn't provide images. So I wrote my own. Mine is simple, I simply just return all the data between two values function smarty_function_getlang($params, &$smarty){ require_once 'outside_file.php'; foreach($params as $key => $value) { $$key = $value; } return OUTSIDE_FUNCTION::substr_delimeters($data, '<' . $lang . '>', '</' . $lang . '>'); } static function substr_delimeters($inputstr,$delimeterLeft,$delimeterRight) { if (empty($inputstr) || empty($delimeterLeft) || empty($delimeterRight)) return false; $posLeft = stripos($inputstr,$delimeterLeft)+strlen($delimeterLeft); $posRight = stripos($inputstr,$delimeterRight,$posLeft+1); if (($posLeft===false) || ($posRight===false)) return false; return substr($inputstr,$posLeft,$posRight-$posLeft); } 0 Quote Link to comment Share on other sites More sharing options...
Yonsee Posted May 29, 2014 Share Posted May 29, 2014 Hi. I'm trying to use the plugin and It's working quite fine, but I have an issue: It works properly with the description of the packages but not with the name. I used the option {debug} to see ve values from the variables and I discovered something strange: name => "<english>Wordpress will be inst..." description => "<english>Wordpress will be installed ..." I think this is the reason why is not working with the names: the function SimpleXMLElement($xmldata); is not recognizing the text as XML because there is no < >. any idea how to solve that? I think It could be done if there is any php function that allows to change a character o character string inside the variable, but i don't know if there is something like That. 0 Quote Link to comment Share on other sites More sharing options...
Yonsee Posted June 4, 2014 Share Posted June 4, 2014 Solved. If there is somebody with the same problem (now or in the future) this is my solution. adding to lines in the code: $xmldata=str_replace('<','<',$xmldata); $xmldata=str_replace('>','>',$xmldata); after $xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.$params['data'].'</root>'; 0 Quote Link to comment Share on other sites More sharing options...
ErnestoC Posted January 19, 2015 Share Posted January 19, 2015 Hi, thanks for this plugin, it works great! I just have a question... For configurable products I add on my configureproduct.tpl the code {getlang data=$options.name lang=$language} and the Option name shows in the selected language but the price disappears . Any way to make this work? Thanks! Ernesto 0 Quote Link to comment Share on other sites More sharing options...
jacksoggetto Posted September 30, 2015 Share Posted September 30, 2015 I'm using this on version six File should be put here: WHMCS/vendor/smarty/smarty/libs/plugins/function.getlang.php I'm using the hack described by Yonsee for < and > language name have to be all lowercase, ex: <english>en</english><spanish>es</spanish> 0 Quote Link to comment Share on other sites More sharing options...
jacksoggetto Posted October 1, 2015 Share Posted October 1, 2015 I made (hopefully) an improvement. Using this function (instead of the original one) you take away from a string (title, description, payment gateway name, whatever) the text enclosed in html tags so even if I have a string like (for example in the sidebar of Version six, or in some other cases): Addons (ogbuhOBUH.gvyibuhonij.it) - <italian>IP dedicato (mensile)</italian><english>Dedicated IP (Monthly)</english> (01/10/2015 - 31/10/2015) it takes away every thing enclosed in HTML tags but the text enclosed in you target language tags. If you want to keep certain html tags just add them in the $tags variable, so that they will not be deleted This way we can translate the invoices. Also, the code you have to add in your template is the same so you only have top modify your function <?php /* * Smarty plugin * ————————————————————- * File: function.getlang.php * Type: function * Name: XML Language Data * Purpose: Returns only the language data surrounded by language tags * ————————————————————- */ function smarty_function_getlang($params, &$smarty){ $deflang = "english"; $lang = $params['lang']; $text = $params['data']; if (strpos($text, $lang) == false) { $lang = $deflang; } $text=str_replace('<','<',$text); $text=str_replace('>','>',$text); $tags = "<$lang>,<strong>,<br>"; preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags); $tags = array_unique($tags[1]); if(is_array($tags) AND count($tags) > 0) { if($invert == FALSE) { return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text); } else { return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?</\1>@si', '', $text); } } elseif($invert == FALSE) { return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text); } return $text; } ?> - - - Updated - - - I'm still trying to figure out how to add this in the pdf invoice tough 0 Quote Link to comment Share on other sites More sharing options...
jacksoggetto Posted October 1, 2015 Share Posted October 1, 2015 to solve with the pdf invoices I came out with the following solution. I changed this code: foreach ($invoiceitems as $item) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($item['description']) . '<br /></td> <td align="center">' . $item['amount'] . '</td> </tr>'; } with: foreach ($invoiceitems as $item) { $text = $item['description']; $lang = Lang::trans('language_name'); $text=str_replace('<','<',$text); $text=str_replace('>','>',$text); $tags = "<$lang>,<strong>,<br>,<input>,<select>,<option>"; preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags); $tags = array_unique($tags[1]); if(is_array($tags) AND count($tags) > 0) { $text = preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text); } else { $text = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text); } $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">' . nl2br($text) . '<br /></td> <td align="center">' . $item['amount'] . '</td> </tr>'; } I had to create a language variable "language_name": $_LANG["language_name"] = "english"; 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.