Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Language linked to URL


jannezz

Recommended Posts

Posted

Hi all,

 

I'm trying to link the language on the domainname.

I've got a .nl and a .com domainname.

I want it to be that if you enter website via the .com the language will be english for the rest of the visit,

and if you visit the .nl domainname at first the language must be - and stay - dutch.

 

The whole shop runs within the .nl domainname. So if you enter the .com version, you're next link will lead to the .nl/* version.

 

Kind regards,

Posted
Hi all,

 

I'm trying to link the language on the domainname.

I've got a .nl and a .com domainname.

I want it to be that if you enter website via the .com the language will be english for the rest of the visit,

and if you visit the .nl domainname at first the language must be - and stay - dutch.

 

The whole shop runs within the .nl domainname. So if you enter the .com version, you're next link will lead to the .nl/* version.

 

Kind regards,

 

 

I'm crap at this so try at your own risk :blink:

 

in .htaccess try ..

 

RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.mysite.nl/index.php?language=en/$1

 

I don't hold out much hope tbh but give it a go. Obviously changing the mysite

Posted

And yes i can check wether the user entered the website using the .com or .nl extension.

 

This is some code from the application_top.php

  $domein_ext = explode (".", $_SERVER['HTTP_HOST']);
 if ($domein_ext[2] == "nl") { 
  $language_code= "dutch"; $language_id = "4";
 } else { 
  $language_code= "english"; $language_id = "1";
 }

$lng->set_language($language_code);

 

But is still will not work,

The session isn't set right...

What to do with this part :

 

 tep_session_register('language');
tep_session_register('languages_id');

Posted

Try near the very top of application_top.php

 

  $domein_ext = explode (".", $_SERVER['HTTP_HOST']);
if (!isset($HTTP_GET_VARS['language'])) // Make sure the user has not requested a language
 if ($domein_ext[2] == "com") {
  $HTTP_GET_VARS['language'] = 'en';
 }

Posted

That works fine for selecting the right language when entering the store on .com or .nl

But as soon as you click - and entered by a .com domain - you will be directed to the .nl version of the website, with dutch spelling. So the sessions need to be set right ...

How to do that ?

Posted

Ok I'm finding this a bit tough as I can't test but try this ..

 

In application_top.php find ..

 

// set the language

 

 

Add directly ABOVE

 

if (!isset($HTTP_GET_VARS['language'])) { // Make sure the user has not requested a language
  $domein_ext = explode (".", $_SERVER['HTTP_HOST']);
  if ($domein_ext[2] == "com") {
  $HTTP_GET_VARS['language'] = 'en';
  $_SESSION['show_english'] = 'on';
  }elseif ( (isset($_SESSION['show_english'])) && ($_SESSION['show_english'] == 'on') ) {
	   $HTTP_GET_VARS['language'] = 'en';
	   unset($_SESSION['show_english']);
  }
}

Posted

I've adjusted the code above and now it's working fine !

 

if (!isset($HTTP_GET_VARS['language'])) { // Make sure the user has not requested a language
if (isset($_SERVER['HTTP_REFERER'])) {
 $domein_ext = explode (".", $_SERVER['HTTP_REFERER']);
} else {
 $domein_ext = explode (".", $_SERVER['HTTP_HOST']);
}
if (!tep_session_is_registered('language')) {
 if ($domein_ext[2] == "nl" || $domein_ext[2] == "nl/") {
  $HTTP_GET_VARS['language'] = 'nl';
 } else { 
  $HTTP_GET_VARS['language'] = 'en';
 }
}
}

Posted

Another method may be ..

 

In application_top.php find ..

 

// set the language

 

 

Add directly ABOVE

 

if (!isset($HTTP_GET_VARS['language'])) { // Make sure the user has not requested a language
  $domein_ext = explode (".", $_SERVER['HTTP_HOST']);
  if ($domein_ext[2] == "com") {
  $HTTP_GET_VARS['language'] = 'en';
  }elseif ($_SERVER['HTTP_REFERER'] == 'mycomdomain.com') ) {  // Change mycomdomain.com
	   $HTTP_GET_VARS['language'] = 'en';
  }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...