View Full Version : Getting current language in Templates?
Hal9000
02-26-10, 08:00 AM
Hello!
My WHMCS is running with several languages, and I want to customize a template file in that it loads a different image depending on the current language.
However, is there a variable I can use in the template that contains the current language name?
Hal9000
02-26-10, 09:08 AM
lol that was easy :) thank you!
Has the $language variable changed in the latest WHMCS version?
I am using following to select either Dutch or the standard language when calling a template:
# Define the template filename to be used without the .tpl extension
if ($language == "NL-Dutch")
{
$templatefile = "aboutus-nl";
}
else
{
$templatefile = "aboutus";
}
outputClientArea($templatefile);
This worked fine until the latest version. Now after displaying the Dutch once it switches back to the default language.
Any ideas how to fix this?
Try this:
if ($smarty->_tpl_vars['language'] == "Dutch")
$templatefile = "aboutus-nl";
else
$templatefile = "aboutus";
outputClientArea($templatefile);
Hi M00
That works just great, thank you!
I also just found a way to select the language in the template using $language and an if statement.
So now I have 2 ways to do the job... Hm, which one will I take now... ;)
additional question:
is the Smarty var $filename new in v4.2.1?
Not sure, but something must have changed as my solution worked fine before the upgrade to v4.2.1
As I asked Matt the same question as above he answered:
I don't think $language is a variable that would be defined in custom pages. $_SESSION['Language'] is where the currently selected language is stored if different from the default.
Not sure about how to use $_SESSION['Language'] though...
Hi M00
That works just great, thank you!
I also just found a way to select the language in the template using $language and an if statement.
So now I have 2 ways to do the job... Hm, which one will I take now... ;)
That was the actual thing I meant in my first reply, but it will work both. :)
additional question:
is the Smarty var $filename new in v4.2.1?
No
EDIT:
Not sure, but something must have changed as my solution worked fine before the upgrade to v4.2.1
As I asked Matt the same question as above he answered:
Not sure about how to use $_SESSION['Language'] though...
I would recommend to use the language defined inside Smarty. This is just the language how it shows it the customer.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.