Jump to content

[solved] set default front office language, override cookie and browser language


Recommended Posts

Hi

 

I have 2 languages on my prestashop 1.5.3 website, English and French. I would like to always display the front office in English (wherever the user is from) and let the user the possibilty to switch to French if he really wants it.

 

Can you help me figure ou thow to force English in Front office ?

 

Thanks

Link to comment
Share on other sites

I just visited your shop and see default of English.

 

This can be for two reasons:

 

1. your last visit to the shop, you used French, this is recorded in browse cookie and will be used next time your visit shop.  Clear cookie.  (but this may still display French, see 2)

2. your browsers (ff/explorer/etc) primary language is French, and no previous cookie will set shop language to French.  If your primary browser language is French, and you  want to see your shop in English (and no previous cookie), then set your browse language to English.

 

:)

Link to comment
Share on other sites

  • 6 months later...

Hi louissss,

 

After I have struggled with this problem, I found a way to stop Prestashop 1.6.0.9  from automatic language detection and change to browser selected language. This helped me to stop Location Detection & Redirect users to their browser language automatically.

 

First back-up the files: Cookie.php and Tools.php

 

1. Modify site/classes/Cookie.php  >> on line 307
 

   $this->detect_language = true;   with
   $this->detect_language = false;

 

2. Modify site/classes/Tools.php >> on line 350 and at the end of the line 368 add    /* */

   

/* Automatically detect language if not already defined, detect_language is set in Cookie::update */

/* if ((!$cookie->id_lang || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$array  = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
$string = $array[0];
 
if (Validate::isLanguageCode($string))
{
$lang = Language::getLanguageByIETFCode($string);
if (Validate::isLoadedObject($lang) && $lang->active && $lang->isAssociatedToShop())
{
Context::getContext()->language = $lang;
$cookie->id_lang = (int)$lang->id;
}
}
}
 
if (isset($cookie->detect_language))
unset($cookie->detect_language); */
 
 I haven't tested it very intensively, but it seems to work.  
 
PS: Don't forget to change default language in Prestashop BO to your desired language and delete browser cookies. 
  • Like 1
Link to comment
Share on other sites

  • 2 years later...

 

Hi louissss,

 

After I have struggled with this problem, I found a way to stop Prestashop 1.6.0.9  from automatic language detection and change to browser selected language. This helped me to stop Location Detection & Redirect users to their browser language automatically.

 

First back-up the files: Cookie.php and Tools.php

 

1. Modify site/classes/Cookie.php  >> on line 307

 

   $this->detect_language = true;   with

   $this->detect_language = false;

 

2. Modify site/classes/Tools.php >> on line 350 and at the end of the line 368 add    /* */

   

/* Automatically detect language if not already defined, detect_language is set in Cookie::update */

/* if ((!$cookie->id_lang || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$array  = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
$string = $array[0];
 
if (Validate::isLanguageCode($string))
{
$lang = Language::getLanguageByIETFCode($string);
if (Validate::isLoadedObject($lang) && $lang->active && $lang->isAssociatedToShop())
{
Context::getContext()->language = $lang;
$cookie->id_lang = (int)$lang->id;
}
}
}
 
if (isset($cookie->detect_language))
unset($cookie->detect_language); */
 
 I haven't tested it very intensively, but it seems to work.  
 
PS: Don't forget to change default language in Prestashop BO to your desired language and delete browser cookies. 

 

 

why would one every do this?  if visitor has language preference then serve them, this just breaks the concept of visitor localization,  is a step back not forward.

Link to comment
Share on other sites

×
×
  • Create New...