Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Automatic language selection


John Jesen

Recommended Posts

Posted

Is this functionality standard now in MS2? There is a contrib for this (MS1), but I guess no need to install it if it already is implemented, but I am a little unsecure about whether this is actually the case.

 

How does this language detection work ? I suppose the languages in OSC need to be named in a way that the browser can identify, but is that English country names, ie. "Danish" rather than "Dansk" or ???

 

This subject is a little hard to test unless you have access to more PC's with different language setup's

 

Thanks for any help!

 

John

Posted

Check in includes/application_top.php around line 216 for this:

// verify the browser user agent if the feature is enabled

 if (SESSION_CHECK_USER_AGENT == 'True') {

   $http_user_agent = getenv('HTTP_USER_AGENT');

   if (!tep_session_is_registered('SESSION_USER_AGENT')) {

     $SESSION_USER_AGENT = $http_user_agent;

     tep_session_register('SESSION_USER_AGENT');

   }



   if ($SESSION_USER_AGENT != $http_user_agent) {

     tep_session_destroy();

     tep_redirect(tep_href_link(FILENAME_LOGIN));

   }

 }

 

HTH

The_Bear

Posted

Yes, I have this code in application_top.php at the mentioned location, but further down it says:

// set the language

 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {

   if (!tep_session_is_registered('language')) {

     tep_session_register('language');

     tep_session_register('languages_id');

   }



   include(DIR_WS_CLASSES . 'language.php');

   $lng = new language();



   if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {

     $lng->set_language($HTTP_GET_VARS['language']);

   } else {

     $lng->get_browser_language();

   }



   $language = $lng->language['directory'];

   $languages_id = $lng->language['id'];

 }

 

I guess it is here that language - maybe (I can't look throgh the code) - are being set.

 

But if yes, could you then tell how to name my languages i OSC? Thanks.

 

John

Posted

From the previous answer I guess that some kind of automatic language detection is included in osCommerce (must admit that I cannot read PHP code).

 

But how does it work? Guess that I have to use some kind of standardized coding for languages in Admin language setup (eg. "en" for english). But how about other languages, eg. Danish, is it "dk", "de", "dn" or.

 

John

Posted

I don't think you have to do anything to set it up. It will automatically read the language of the browser the person is using and set the appropriate language if it has it.

 

So the default installation comes with English, Spanish and German; anyone in Spain or Germany would see their language. But I assume that anyone from, say, France, would see the English version, as that would be the default.

 

I only knew this because I have friends in both Spain and Germany and when I said, "go and look at my fantastic new shop," they said all they could see was a rubbish translation. And I hadn't put any product descriptions or anything, so I was lucky they told me.

Archived

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

×
×
  • Create New...