Ignore:
Timestamp:
Feb 22, 2015, 11:05:49 PM (9 years ago)
Author:
chronos
Message:
  • Remove: Trailing spaces from end of lines from all files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Locale.php

    r619 r815  
    11<?php
    22
    3 class LocaleText 
     3class LocaleText
    44{
    55        var $Data;
     
    1212        $this->Code = 'en';
    1313        $this->Title = 'English';
    14   }     
    15  
     14  }
     15
    1616        function Load()
    1717        {
    1818        }
    19        
     19
    2020        function Translate($Text)
    21         {       
     21        {
    2222                if(array_key_exists($Text, $this->Data) and ($this->Data[$Text] != ''))
    2323                  return($this->Data[$Text]);
    2424                  else return($Text);
    25         }       
     25        }
    2626}
    2727
     
    3030        var $Texts;
    3131        var $Dir;
    32        
     32
    3333        function __construct($System)
    3434        {
     
    3636                $this->Texts = new LocaleText();
    3737        }
    38        
     38
    3939        function Load($Language)
    4040        {
     
    4242                if(file_exists($FileName)) {
    4343                        include_once($FileName);
    44                         $ClassName = 'LocaleText'.$Language;                   
     44                        $ClassName = 'LocaleText'.$Language;
    4545                  $this->Texts = new $ClassName();
    4646                } else throw new Exception('Language file '.$FileName.' not found');
    4747                $this->Texts->Load();
    4848        }
    49        
     49
    5050        function AnalyzeCode($Path)
    5151  {
     
    6060      else if(file_exists($FullName))
    6161      {
    62         if(substr($FullName, -4) == '.php') 
     62        if(substr($FullName, -4) == '.php')
    6363        {
    6464                $Content = file_get_contents($FullName);
    6565                // Search occurence of T() function
    6666                while(strpos($Content, 'T(') !== false)
    67                 { 
     67                {
    6868                        $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1));
    6969                        $Content = substr($Content, strpos($Content, 'T(') + 2);
     
    7171                        //echo($Ord.',');
    7272                        if(!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
    73                         {       
    74                                 // Do for non-alpha previous character                                           
     73                        {
     74                                // Do for non-alpha previous character
    7575                          $Original = substr($Content, 0, strpos($Content, ')'));
    7676                          $Original2 = '';
    77                           if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'")) 
     77                          if((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))
    7878                            $Original2 = substr($Original, 1, -1);
    79                           if((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"')) 
    80                             $Original2 = substr($Original, 1, -1);                       
    81                           if($Original2 != '') 
     79                          if((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))
     80                            $Original2 = substr($Original, 1, -1);
     81                          if($Original2 != '')
    8282                          {
    8383                                if(!array_key_exists($Original2, $this->Texts->Data))
    8484                                  $this->Texts->Data[$Original2] = '';
    85                           } 
     85                          }
    8686                        }
    87                 }               
    88         }         
    89       }           
     87                }
     88        }
     89      }
    9090    }
    9191  }
    92  
     92
    9393  function SaveToFile($FileName)
    9494  {
     
    111111    file_put_contents($FileName, $Content);
    112112  }
    113  
     113
    114114  function LoadFromDatabase($Database, $LangCode)
    115115  {
     
    150150          $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
    151151          '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item));
    152           else $Database->insert('Locale', array('Language' => $Language['Id'], 
     152          else $Database->insert('Locale', array('Language' => $Language['Id'],
    153153         'Original' => $Index, 'Translated' => $Item));
    154154      }
     
    162162        var $Codes;
    163163        var $Dir;
    164        
     164
    165165        function __construct($System)
    166166        {
    167167                parent::__construct($System);
    168168                $this->Codes = array('en');
    169                 $this->CurrentLocale = new LocaleFile($System);         
    170         }
    171        
     169                $this->CurrentLocale = new LocaleFile($System);
     170        }
     171
    172172        function LoadAvailable()
    173173        {
     
    177177    {
    178178          if(substr($FileName, -4) == '.php')
    179           {             
     179          {
    180180                $Code = substr($FileName, 0, -4);
    181181                $Locale = new LocaleFile($this->System);
     
    183183                $Locale->Load($Code);
    184184                $this->Available['Code'] = array('Code' => $Code, 'Title' => $Locale->Texts->Title);
    185           } 
     185          }
    186186          }
    187187  }
    188        
     188
    189189        function UpdateAll($Directory)
    190190        {
     
    195195    {
    196196          if(substr($FileName, -4) == '.php')
    197           {             
     197          {
    198198                  $FileLocale = new LocaleFile($this->System);
    199                   $FileLocale->Dir = $this->Dir;                 
     199                  $FileLocale->Dir = $this->Dir;
    200200                  $FileLocale->Load(substr($FileName, 0, -4));
    201                  
     201
    202202                  // Add new
    203203                  foreach($Locale->Texts->Data as $Index => $Item)
     
    215215        $this->CurrentLocale->Load($this->CurrentLocale->Texts->Code);
    216216        }
    217        
     217
    218218        function LoadLocale($Code)
    219219        {
     
    227227{
    228228        global $LocaleManager;
    229        
     229
    230230        if(isset($LocaleManager)) return($LocaleManager->CurrentLocale->Texts->Translate($Text));
    231231          else return($Text);
Note: See TracChangeset for help on using the changeset viewer.