Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I18N change default frontend language
#1
I have searched and search in the forum and internet how to change the default frontend language but I can't find nothing. My site has 4 languages:
EN,AL,RO,IT and the default language is set to EN. I tried to change from admin the language to sq but without success and is to complicated to rename all the pages.
I was wondering if I can make a SESSION before the site loads for the first time in a browser .
SESSION starts when the site is loaded and set the language to AL and the site loads,Then the SESSION stops because I don't want to set e session each time I load the page. Am I in the right direction or I should use cookies.
I am not an expert in PHP but I am trying to find a solution Smile
Anyone can help me with a logic direction or code?
Thanks in advance
Reply
#2
I think I found a solution for this problem. What I did is uncomment in gsconfig
PHP Code:
#define('I18N_IGNORE_USER_LANGUAGE',true); 
and then edit in frontend.class.php from
PHP Code:
public static function getLanguages() {
    if (!
self::$languages) {
      
self::$languages = array();
      if (isset(
$_GET[I18N_LANGUAGE_PARAM])) {
        
self::$languages[] = $_GET[I18N_LANGUAGE_PARAM];
      }
      if (isset(
$_SESSION[I18N_LANGUAGE_KEY]) && !in_array($_SESSION[I18N_LANGUAGE_KEY],self::$languages)) {
        
self::$languages[] = $_SESSION[I18N_LANGUAGE_KEY];
      }
      if (!
defined('I18N_IGNORE_USER_LANGUAGE') || !I18N_IGNORE_USER_LANGUAGE) {
        
$httplanguages explode(",", @$_SERVER['HTTP_ACCEPT_LANGUAGE']);
        foreach (
$httplanguages as $language) {
          
$language substr($language,0,2);
          if (!
in_array($language,self::$languages)) self::$languages[] = $language;
        }
      } 

to
PHP Code:
public static function getLanguages() {
    if (!
self::$languages) {
      
self::$languages = array();
      if (isset(
$_GET[I18N_LANGUAGE_PARAM])) {
        
self::$languages[] = $_GET[I18N_LANGUAGE_PARAM];
      }
      if (isset(
$_SESSION[I18N_LANGUAGE_KEY]) && !in_array($_SESSION[I18N_LANGUAGE_KEY],self::$languages)) {
        
self::$languages[] = $_SESSION[I18N_LANGUAGE_KEY];
      }
      if (!
defined('I18N_IGNORE_USER_LANGUAGE') || !I18N_IGNORE_USER_LANGUAGE) {
        
$httplanguages explode(",", @$_SERVER['HTTP_ACCEPT_LANGUAGE']);
        foreach (
$httplanguages as $language) {
          
$language "sq";
          if (!
in_array($language,self::$languages)) self::$languages[] = $language;
        }
      } 
and now my default language is albanian. You see any problem/ risk in this modification ?
Thanks
Reply




Users browsing this thread: 1 Guest(s)