Jump to content

MOD : Multilingual Products (in fact any value you want)


Did you find this mod useful?  

87 members have voted

  1. 1. Did you find this mod useful?

    • Yes
      83
    • No
      4


Recommended Posts

  • Replies 85
  • Created
  • Last Reply

Top Posters In This Topic

I'm on 4.2.1, and only interested for product (name and description) and KB categories.

 

So I copied the first script of this thread (only interested in 2 languages, I'm going to delete all the other from the folder)

 

<?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'];

}

}

}

?>

 

and put in:

/whmcs/includes/smarty/plugins/function.getlang.php

 

then I edited the product name of one product in this way:

<Italian>Piano base</Italian><English>Basic plan</English>

 

and then edited the first piece of the template:

from:

{$product.name}

to:

{getlang data=$product.name lang=$language}

 

but i get:

<Italian>Piano base</Italian><English>Basic plan</English>

 

So nothing happens.

 

I've tried to delete the function file, and I get white page.

 

Do you have some advice?

Link to comment
Share on other sites

  • 3 weeks later...
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 I'm not sure where I need put this code :

{getlang data=$product.name lang=$language} and

 

<English>English content</English><French>French content</French

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...
@ServWise.com

 

Have you been able to pass the correct lang values to the pdf invoice? This is the part where I got stuck!!

 

I think already have all files edited and working on Version 4.3.1, Admin area looks like a war zone, though... hehe

 

I second this request.

How to get translations into pdf invoice and into the admin area?

Link to comment
Share on other sites

  • 2 months later...
I second this request.

How to get translations into pdf invoice and into the admin area?

I also like to know how to get this into invoices as there's no use of Smarty?! This snippet is great, but with having something like <English>MyProduct</English><OtherLanguage>MyProduct</OtherLanguage> in invoice it is more or less useless :(

Link to comment
Share on other sites

  • 1 month later...
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,

 

I did create and uploaded the function.getlang.php

Now I am a bit lost...

Link to comment
Share on other sites

  • 1 month later...
It works.

ServWise, if you have a moneybookers account, PLEASE send me a PM with your e-mail address and allow me to send you a small donation for spending your time making this wonderful mod as a small appreciation for making my life easier.

WHMCS is probably the MOST used billing system in the webhosting industry. I never understood why they don't allow EVERYTHING to be translatable in other languages.

Thank you, I mean alot.

 

One question... Does this works for knowledge base categories and articles? If yes, please someone write instructions as detailed as possible, please.

 

------------

I see you are setup this for you products ....

I can't figure how setup this on my whmcs !! I'm realy appreciate if you help me to make my product french and english language !!

 

I pay you for sure could you please help me ???

 

Thank You

 

Sylvie

Link to comment
Share on other sites

Hi Sylvie,

if you want to take some advice from me: this MOD has some disadvantages. To me the main one was, that in the invoices the product is named <lang1>Product<\lang2><lang2>Produit<\lang2> etc.

ServWise has published another MOD, using the language files: http://forum.whmcs.com/showthread.php?t=22048.

I managed to get this working this weekend for products and productgroups and I still have to figure out how to pull in the translated strings into the invoices. Shouldn't be to difficult as soon as I know what I'm doing :D.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...
  • 4 weeks later...

Hello,

I tried this solution but I have problem on this step:

 

---------------------------------------------------------------------------------------------------------

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}

---------------------------------------------------------------------------------------------------------------

 

I get a smarty error that {getlang data=$product.description lang=$language} is not valid.

I've followed all the steps.

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

To get this worked for the latest version of WHMCS, replace this:

 

$xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.$params['data'].'</root>';

 

with this:

 

$xmldata ='<?xml version="1.0" encoding="ISO-8859-1" ?><root>'.html_entity_decode($params['data']).'</root>';

 

This should work. Try out and have fun ;)

Link to comment
Share on other sites

  • 3 months later...

The only thing i get with your code is } - }.

 

Can you help please.

 

 

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

Link to comment
Share on other sites

  • 4 weeks later...
Hi! What about the new version of WHMCS 5.0.3? If your hack working with it?

 

Why does the Team from WHMCS do ignore this Point ??

A System what will sell as a multi lnaguage System shouldt be a multi language system.

 

I read this Thread and see, there is no statement in all from WHMCS. So i cant tell my Clients in Bulgary, they have to learn German or English, because the Software dont want work here correct..

 

It was nice to have a timeline ! - In old System i add this Code 4.5.1. and it works.

But each Update i begin all Changes again. So i want to work with it, not to play..

 

We cant change it self - it is encoded !

A good Idea was, that the Team from WHMCS decode some Parts of this, that Users here have the chance to make a correct Translation parts for all...

 

I love WHMCS, but if it not go ahead with multi Language - then i cant use it for all my Servers in all.

 

Kasi

Link to comment
Share on other sites

  • 4 weeks later...
Why does the Team from WHMCS do ignore this Point ??

A System what will sell as a multi lnaguage System shouldt be a multi language system.

 

I read this Thread and see, there is no statement in all from WHMCS. So i cant tell my Clients in Bulgary, they have to learn German or English, because the Software dont want work here correct..

 

It was nice to have a timeline ! - In old System i add this Code 4.5.1. and it works.

But each Update i begin all Changes again. So i want to work with it, not to play..

 

We cant change it self - it is encoded !

A good Idea was, that the Team from WHMCS decode some Parts of this, that Users here have the chance to make a correct Translation parts for all...

 

I love WHMCS, but if it not go ahead with multi Language - then i cant use it for all my Servers in all.

 

Kasi

 

You are absolutely right! WHMCS Team should pay attention to that problem...

And this hack doesnt working with WHMCS 5.0.3. :(

Link to comment
Share on other sites

  • 2 months later...

It's incredible WHMCS (claiming to be multi-language) doesn't let translate the more important: the product names and descriptions!...

 

I was going to give a try to this solution, but finally isn't it working for 5.0.3 version ?

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated