Your basket is empty.

Items in cart: 0
Total: $0.00

PayPaleBay's service!
Visa Mastercard
iDEAL
Search: Advanced Search

Found nothing? Look at:

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…


Powered by CubeCart