Skip to content

Instantly share code, notes, and snippets.

@EvaldasUzkuras
Created June 12, 2014 07:18
Show Gist options
  • Save EvaldasUzkuras/0a8354521fdd0fc07c9e to your computer and use it in GitHub Desktop.
Save EvaldasUzkuras/0a8354521fdd0fc07c9e to your computer and use it in GitHub Desktop.
Turn off automatic language detection - Prestashop
<?php
class Tools extends ToolsCore
{
/**
* Change language in cookie while clicking on a flag
*
* @return string iso code
*/
public static function setCookieLanguage($cookie = null)
{
if (!$cookie)
$cookie = Context::getContext()->cookie;
/* If language does not exist or is disabled, erase it */
if ($cookie->id_lang)
{
$lang = new Language((int)$cookie->id_lang);
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
$cookie->id_lang = null;
}
/* If language file not present, you must use default language file */
if (!$cookie->id_lang || !Validate::isUnsignedId($cookie->id_lang))
$cookie->id_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$iso = Language::getIsoById((int)$cookie->id_lang);
@include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php');
return $iso;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment