Ignore:
Timestamp:
Jan 12, 2016, 10:33:43 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Improved language switching using language code in URL. This is more search engine friendly as each language have own fixed URL.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Locale.php

    r840 r841  
    162162  var $Codes;
    163163  var $Dir;
     164  var $LangCode;
     165  var $DefaultLangCode;
     166  var $Available;
    164167
    165168  function __construct(System $System)
     
    168171    $this->Codes = array('en');
    169172    $this->CurrentLocale = new LocaleFile($System);
     173    $this->LangCode = 'en';
     174    $this->DefaultLangCode = 'en';
     175    $this->Available = array();
    170176  }
    171177
     
    218224  function LoadLocale($Code)
    219225  {
    220     $this->CurrentLocale->Dir = $this->Dir;
    221     $this->CurrentLocale->Load($Code);
     226    if(array_key_exists($Code, $this->Available))
     227    {
     228      $this->CurrentLocale->Dir = $this->Dir;
     229      $this->CurrentLocale->Load($Code);
     230    } else throw new Exception('Unsupported locale code '.$Code);
    222231  }
    223232}
     
    226235function T($Text)
    227236{
    228   global $LocaleManager;
    229 
    230   if(isset($LocaleManager)) return($LocaleManager->CurrentLocale->Texts->Translate($Text));
     237  global $GlobalLocaleManager;
     238
     239  if(isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text));
    231240    else return($Text);
    232241}
Note: See TracChangeset for help on using the changeset viewer.