d3m0n Posted May 19, 2009 Share Posted May 19, 2009 Hey Man grate mod , thx for sharing with the crowd i am getting some trouble with applying it getting this on the output English contentFrench content , even when i am switching the langs i have done all steps 1. added code to function.getlang.php file and uploaded to libs/plugins 2. added {getlang data=$product.name lang=$language} and description to products.tpl file in order form 3. added <English>English content</English><French>French content</French> via admin to my product description no luck please advise Kind Regards 0 Quote Link to comment Share on other sites More sharing options...
ServWise.com Posted May 19, 2009 Author Share Posted May 19, 2009 1. added code to function.getlang.php file and uploaded to libs/plugins The script needs to be created/uploaded in to /whmcs/includes/smarty/plugins/function.getlang.php (whmcs being the folder where you have installed whmcs) not libs/plugins. 0 Quote Link to comment Share on other sites More sharing options...
d3m0n Posted May 19, 2009 Share Posted May 19, 2009 ohh i was trying to install onto 3.8.6 thx for help 0 Quote Link to comment Share on other sites More sharing options...
jozeph Posted May 19, 2009 Share Posted May 19, 2009 3.8.6? Where you get this version? 0 Quote Link to comment Share on other sites More sharing options...
equipc Posted June 18, 2009 Share Posted June 18, 2009 $data = str_replace("[##","<",$data); $data = str_replace("[#","]]></",$data); $data = str_replace("<p>[##","<",$data); $data = str_replace("<p>[#","]]></",$data); $data = str_replace("##]",">",$data); $data = str_replace("##]</p>",">",$data); $data = str_replace("#]","><![CDATA[",$data); $data = str_replace("#]</p>","><![CDATA[",$data); $data = str_replace("##][##","><",$data); fix for non wywiwyg strings. You forgot the regular [##, [#, #] and ##] tags... This code is not correct ! But the following will works ! (You first have to check with <p> tags before ;-) $data = str_replace("<p>[##","<",$data); $data = str_replace("<p>[#","]]></",$data); $data = str_replace("[##","<",$data); $data = str_replace("[#","]]></",$data); $data = str_replace("##]</p>",">",$data); $data = str_replace("##]",">",$data); $data = str_replace("#]</p>","><![CDATA[",$data); $data = str_replace("#]","><![CDATA[",$data); $data = str_replace("##][##","><",$data); 0 Quote Link to comment Share on other sites More sharing options...
cyberneticos Posted June 29, 2009 Share Posted June 29, 2009 I would like to see this implemented also. MAkes no sense to have a language selector, but stuck with only one language for the most important aspect of selling (the store front) 0 Quote Link to comment Share on other sites More sharing options...
cyberneticos Posted June 29, 2009 Share Posted June 29, 2009 even if I use this mod, I am stuck with uni-language invoice system. arrghhh 0 Quote Link to comment Share on other sites More sharing options...
jozeph Posted July 1, 2009 Share Posted July 1, 2009 I'm using this plugin and it solve problems with multi-language. I recommend for all due Matt said me that have no plans at this time to add multi-language in some areas of WHMCS. 0 Quote Link to comment Share on other sites More sharing options...
cyberneticos Posted July 1, 2009 Share Posted July 1, 2009 What about invoices ? 0 Quote Link to comment Share on other sites More sharing options...
klemens Posted October 23, 2009 Share Posted October 23, 2009 Thanks for great mod But to use all characters you should change xml coding to UTF-8. Otherwise it will display some characters incorrectly. $xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.$params['data'].'</root>'; to $xmldata ='<?xml version="1.0" encoding="UTF-8" ?><root>'.$params['data'].'</root>'; 0 Quote Link to comment Share on other sites More sharing options...
Marcus Posted November 6, 2009 Share Posted November 6, 2009 Hey, nice mod ... any idea how can i use {... |truncate:150:"..."} with this mod ? regards marcus 0 Quote Link to comment Share on other sites More sharing options...
sino Posted November 8, 2009 Share Posted November 8, 2009 (edited) Hi, Thank you for your great contribution. I've followed all the steps carefully. However, I got the following output: Product Description English content Chinese content ... Group Name <English>English content></English><Chinese>Chinese content</Chinese>... http://www.sinoland.com/whmcs/cart.php?language=English The database value of product groups name is <English>Industry Web Hosting</English> Please help. Thank you. Edited November 8, 2009 by sino 0 Quote Link to comment Share on other sites More sharing options...
sino Posted November 8, 2009 Share Posted November 8, 2009 Hi, My database is utf8_unicode_ci. When I change all '<' to '<' and '>' to '>' via phpMyAdmin. It works. So how can I correct this issue? That is, '<' and '>' entered into admin. would be saved as '<' and '>' in the database respectively. I'm not good at those encoding and database. Please help. Thank you in advance. 0 Quote Link to comment Share on other sites More sharing options...
Marcus Posted November 8, 2009 Share Posted November 8, 2009 Anyone an idea how to use it with kbsuggestions ? 0 Quote Link to comment Share on other sites More sharing options...
sino Posted November 9, 2009 Share Posted November 9, 2009 Hi, It works now. I thought the latest version upgrade is for WYSIWYG editor only. Thank you. 0 Quote Link to comment Share on other sites More sharing options...
plusplushosting Posted November 15, 2009 Share Posted November 15, 2009 Hi guys, great plugin but im not being able to get it working....it showing the language tags and all the info like: <English>This is English</English><Italian>Questo è l'italiano</Italian> in the product group im using v 4.1.2 of whmcs any idea? Should i have to reload something after create the plugin file in the smarty plugin directory? Thanx in advance! 0 Quote Link to comment Share on other sites More sharing options...
alain100 Posted January 3, 2010 Share Posted January 3, 2010 Hi, nice solution but it just does not work in the view cart product configuration page. I still get the <English>group name</English><French.> etc.. tags. Any idea how to fix this? I would really appreciate Thanks 0 Quote Link to comment Share on other sites More sharing options...
sino Posted March 25, 2010 Share Posted March 25, 2010 Hi,nice solution but it just does not work in the view cart product configuration page. I still get the <English>group name</English><French.> etc.. tags. Any idea how to fix this? I would really appreciate Thanks Hi, I encounter the same issue and discover that I forget to update the variable, say $groupname to {getlang data=$groupname lang=$language} in clientareaproductdetails.tpl. Have to update all variables in concern. Possible variables/files to update: {$product.productinfo.groupname} {$product.productinfo.name} viewcart.tpl (Web20cart) Hope this helps. Regards, Sino 0 Quote Link to comment Share on other sites More sharing options...
Sylvie Posted April 23, 2010 Share Posted April 23, 2010 Here is an updated script and some instructions for allowing multi-language content in WYSIWYG editor fields. Please note this is somewhat of a hack and you need to be careful exactly how you structure the page to make sure no stray html code gets trapped between tags (p tags surrounding the tags are okay and in fact have to be there for the sudo tag conversion to work ) In the WYSIWYG editor you can place the sudo codes surrounding your content like so [##English#] This is english [#English##] [##Italian#] This is Italian [#Italian##] The html should come out something like this <p>[##English#]</p> <p>This is english</p> <p>[#English##]</p> <p>[##Italian#]</p> <p>This is Italian</p> <p>[#Italian##]</p> Please make sure that no additional p tags (Apart from the ones above which are catered for) fall outside of the surrounding tags or likely the conversion will not work and the whole string will be outputted instead. The modified script to is below, enjoy <?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){ // Set a default language $deflang ="English"; // Convert sudocode from wysiwyg editor $data = str_replace("<p>[##","<",$params['data']); $data = str_replace("<p>[#","]]></",$data); $data = str_replace("##]</p>",">",$data); $data = str_replace("#]</p>","><![CDATA[",$data); $data = str_replace("##][##","><",$data); // process data $xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.$data.'</root>'; $lang = $params['lang']; if(simplexml_load_string($xmldata)===FALSE) { return $params['data']; } else { $langxmlobj = new SimpleXMLElement($xmldata); if ($langxmlobj->$lang){ return $langxmlobj->$lang; } elseif ($langxmlobj->$deflang){ return $langxmlobj->$deflang; } else { return $params['data']; } } } ?> I noticed that WHMCS is lacking in the ability to add product titles and descriptions in multiple languages and although there is a mod solution already published http://forum.whmcs.com/showthread.php?t=15045&highlight=products+multiple+languages it is not the most elegant or flexible solution so I decided to create something better. This solution uses Smarties own plug-in functionality to allows you to easily add multilingual content to any field in the admin. It works by surrounding the content in simple xml tags e.g. <English>English content</English> <French>French content</French> First thing you need to do is create a plug-in file in the following folder /whmcs/includes/smarty/plugins/function.getlang.php and add the following code to the file <?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){ $xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.$params['data'].'</root>'; $lang = $params['lang']; if(simplexml_load_string($xmldata)===FALSE) { return $params['data']; } else { $langxmlobj = new SimpleXMLElement($xmldata); if ($langxmlobj->$lang){ return $langxmlobj->$lang; } else { return $params['data']; } } } ?> Next for any smarty variable that outputs data entered into the admin E.g. the $product.name or $product.description tag in your orderforms you can replace it with the tag below (Note the script will output the full value if no tags are found) {getlang data=$product.name lang=$language} OR {getlang data=$product.description lang=$language} It is then just a simple job or adding the content in the admin with the correct names based on your sites language. <English>English content</English><French>French content</French If anyone finds any bugs then please post them here Hi where i put this code : {getlang data=$product.description lang=$language} 0 Quote Link to comment Share on other sites More sharing options...
mbavio Posted April 26, 2010 Share Posted April 26, 2010 First of all, thanks for this piece of code, it´s really works like charm! But now I found an issue: I want to include html code in product description, and I´m not being able of do it. Let´s put an example: <English> This is plain text <p>This is a paragraph</p> </English> results on: This is plain text Seems like the html code gets removed, and I cant find the solution for that. Can you please help me with that? Thank you! 0 Quote Link to comment Share on other sites More sharing options...
mbavio Posted April 26, 2010 Share Posted April 26, 2010 Update: Shame on me, it´s obvious that is not gonna work with html tags on textarea, it´s being taken as a xml tag by the parser. I changed a bit the code for doing the trick, gonna share it now: <?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){ // Default language $deflang ="English"; if(isset($params['lang'])) $lang = $params['lang']; else $lang = $deflang; $data = $params['data']; $data = str_replace("<","**",$data); $data = str_replace(">","*",$data); $data = str_replace("**" . $lang . "*", "<" . $lang . ">",$data); $data = str_replace("**/" . $lang . "*", "</" . $lang . ">",$data); // process data $xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.$data.'</root>'; if(simplexml_load_string($xmldata)===FALSE) { return $params['data']; } else { $langxmlobj = new SimpleXMLElement($xmldata); if ($langxmlobj->$lang){ $data = str_replace("**","<",$langxmlobj->$lang); $data = str_replace("*",">",$data); return $data; } else { return $params['data']; } } } ?> Please have in mind that this will only work in cases line mine, where you want to add html tags to fields like Product Description. Hope it helps someone! 0 Quote Link to comment Share on other sites More sharing options...
ServWise.com Posted April 27, 2010 Author Share Posted April 27, 2010 First of all, thanks for this piece of code, it´s really works like charm! But now I found an issue: I want to include html code in product description, and I´m not being able of do it. Let´s put an example: <English> This is plain text <p>This is a paragraph</p> </English> results on: This is plain text Seems like the html code gets removed, and I cant find the solution for that. Can you please help me with that? Thank you! You need to wrap html in <![CDATA ]> tags e.g. <English><![CDATA[html content ]]></English> 0 Quote Link to comment Share on other sites More sharing options...
drhcanada Posted April 29, 2010 Share Posted April 29, 2010 this is great! any way to use it on custom fileds? 0 Quote Link to comment Share on other sites More sharing options...
momilc Posted June 4, 2010 Share Posted June 4, 2010 Hello, everybody I'm new on this forum and new user of WHMCS. I've tried to install the language function on my WHMCS but I must be too dumb. I don't hunderstand what I should really. I'm french (living in france) so I apologize for my english. If someone have time to give me a hand, it will be nice. Thanks in advance Mohamed 0 Quote Link to comment Share on other sites More sharing options...
nathanro Posted July 19, 2010 Share Posted July 19, 2010 Thanks for great mod But to use all characters you should change xml coding to UTF-8. Otherwise it will display some characters incorrectly. to This is good to change, but where (which file and location please). 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.