Currency
British Pounds
Euro
US Dollars
Language
Deutsch
English
Español
Français
Italiano
Norwegian Bokmal
Nederlands
Português
Русский язык
Welcome Guest [
Login
|
Register
]
Shop by Category
Homepage
CubeCart 3.x Mods
Gateway
Shipping
General
CubeCart 4.x Mods
Gateway
General
Shipping
Downloads
General
Sale Items
Robix Support Forum
Free Live Chat Software
Shopping Basket
Your basket is empty.
Items in cart:
0
Total:
$0.00
View Basket
Search:
Advanced Search
Sale Items
CubeCart Amazon Simple Pay gateway
Save $7.50
CubeCart MultiSafepay
Save $7.50
Found nothing? Look at:
Location:
/
CubeCart 3.x Mods
/
General
/User Preferred language
User Preferred language
Product Information
It is always nice for a customer to arrive at your site and be presented in their native language.
This mod presents your shop in the preferred language that is set in the users browser settings.
If none of the users preferred languages is accepted by your shop, then the customer receives the default language that is set in your Admin panel.
To apply the mod modify index.php in your cubecart root.
replace:
if(empty($ccUserData[0]['lang'])){
$lang_folder = $config['defaultLang'];
} else {
$lang_folder = $ccUserData[0]['lang'];
}
include_once("language/".$lang_folder."/lang.inc.php");
With:
function parseHttpAcceptLanguage($DefaultLang)
{
// getting http instruction if not provided
$str=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
// exploding accepted languages
$langs=explode(',',$str);
// creating output list
$accepted=array();
$Count=0;
foreach ($langs as $lang) {
// parsing language preference instructions
// 2_digit_code[-longer_code][;q=coefficient]
ereg('([a-z]{1,2})(-([a-z0-9]+))?(;q=([0-9\.]+))?',$lang,$found);
// 2 digit lang code
$code=$found[1];
// adding if we accept the language
if (file_exists("language/".$code."/lang.inc.php"))
$accepted[$Count++]=$code;
}
//Use the default if none are acceptable
if ($Count==0)$accepted[0] = $DefaultLang;
return $accepted;
}
if(empty($ccUserData[0]['lang'])){
$UserLang = parseHttpAcceptLanguage($config['defaultLang']);
$lang_folder = $UserLang[0];
} else {
$lang_folder = $ccUserData[0]['lang'];
}
include_once("language/".$lang_folder."/lang.inc.php");
The above also applies to confirmed.php and cart.php although the line numbers vary.
Price:
$0.00
Product Code: USER4
Quantity:
Add to Basket
Customers who bought this also bought…
CubeCart Adsense
$0.00
Privacy Policy
|
Terms & Conditions
Powered by
CubeCart