Jump to content

Change WHMCS language through the Website (no in url)


Turcu

Recommended Posts

Hi all, i have a question and i wanted to see if someone have some hint about it.

 

I have a multi-language site, and i am trying to change the WHMCS (integrated inside) language, through source code. I was able to do it before, idk really how (there is not much documentation) but the problem is that stopped working.

 

After much try, what i did before, was when someone changed the language of the website, force all in WHMCS for use these language, for example:

 

if($idiomaActual=="es") $_SESSION["language"]="Spanish";

 

where $idiomaActual is my site language.

 

What i did, was call in my "header.tpl" this functions, that check the language, setted the session variable (that is setted all the time, outside WHMCS too) and all was working fine. Then stopped working (WHMCS update was in the middle too).

 

After much tries, i can't get it working again.

 

I have tried setting:

 

$_SESSION["language"]

$_SESSION["Language"] (in case is case-sensitive problem)

$language (defined as global)

 

But the WHMCS doesn't change the language. Both (site and WHMCS) are in the same domain, so is not session scope problem.

 

I was debbuging the site, and i figured that all the vars (session and local) are correctly setted after all the page loads, so is not some reset problem or similar.

 

If someone has some hint about how to fix it, or if there is some correct way to implement this, i will be very happy :D.

 

Thank you,

regards!

Link to comment
Share on other sites

  • 3 months later...

Hello!

 

I am somewhat in the same situation, trying to set a language from php code outside the whmcs, but no luck yet.

 

When i update the "language" session variable .. it only affects the languages dropdown but contents are not translated.

 

You got solution for your problem or not. If yes, please share.

 

Regards

MT Shahzad

 

http://www.mtshahzad.com

Link to comment
Share on other sites

Hello,

 

I didn't find some correct solution at all.

 

I made if can be helpful for you, a homemade solution that works at least a little. In every language file (in the lang directory), before set the array of language, i ask if these file is the same than the language i have setted. If is not, I don't let continue the script in these file, and i include the right one. Was the most advanced that came to my mind.

 

Regards!

Link to comment
Share on other sites

  • 1 month later...

Hi guys,

 

what i realized until now is that if you have in /lang the files named English.php and english.php, than is changing properly the language .... If you have just English.php, whmcs get error ... and if you leave just english.php the languages are not changing at all ...

 

Personally idk, still, how to fix this issue ... but any hint on how to fix it temporarly will be welcome ...

 

Turcu i don't understand how you setted it up your fixing ...

Link to comment
Share on other sites

 

Turcu i don't understand how you setted it up your fixing ...

 

Hi bitmng,

 

basically what i did, was add in each language file (php file) at the end of the file, the following:

 

if($_SESSION['Language']!="english"){
include(dirname(__FILE__).'/'.$_SESSION['Language'].'.php');	
}

 

Where:

 

$_SESSION['Language'] is the language i have seted with the language i want, but whmcs is not using

and

"english" is the language of the current language file (ex. english.php) where i added the code... "spanish" for spanish.php, and all like this.

 

In this way, this overwrites the $_LANG var with the right language.

 

Regards.

Link to comment
Share on other sites

Hi bitmng,

 

basically what i did, was add in each language file (php file) at the end of the file, the following:

 

if($_SESSION['Language']!="english"){
include(dirname(__FILE__).'/'.$_SESSION['Language'].'.php');	
}

 

Where:

 

$_SESSION['Language'] is the language i have seted with the language i want, but whmcs is not using

and

"english" is the language of the current language file (ex. english.php) where i added the code... "spanish" for spanish.php, and all like this.

 

In this way, this overwrites the $_LANG var with the right language.

 

Regards.

 

sorry I don´t understand. Could you please provide an example?

Link to comment
Share on other sites

sorry I don´t understand. Could you please provide an example?

 

In the folder lang open the file english.php

and go to the end of it - line 1366 of original file

now add a new line and paste the code given by Turcu

 

Next open the other language files, i.e. italian.php

do the same, but this time change english to italian

 

this is for the english.php file

if($_SESSION['Language']!="english"){

include(dirname(__FILE__).'/'.$_SESSION['Language'].'.php');

}

 

this is for italian.php file

if($_SESSION['Language']!="italian"){

include(dirname(__FILE__).'/'.$_SESSION['Language'].'.php');

}

 

this is for french.php file

if($_SESSION['Language']!="french"){

include(dirname(__FILE__).'/'.$_SESSION['Language'].'.php');

}

 

And so on.

Link to comment
Share on other sites

http://forum.whmcs.com/newreply.php?p=284802&noquote=1

 

Hi guys,

 

i spoke with the WHMCS support ... it does work again to me, with this file (overwriting the existing one..) :

http://www.bitmng.com/dbconnect.zip

 

My dbconnect file was dated 3/12, so means that during the last patch has been modified with some code that letted go in error the language function ...

 

Now that i overwrote the file, is working fine again ;)

 

Let me know if is going to solve the issue

Link to comment
Share on other sites

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