Changeset 843 for trunk/includes
- Timestamp:
- Jan 14, 2016, 10:25:47 PM (9 years ago)
- Location:
- trunk/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/Locale.php
r841 r843 18 18 } 19 19 20 function Translate($Text )21 { 22 if(array_key_exists($Text, $this->Data ) and ($this->Data[$Text] != ''))23 return($this->Data[$ Text]);20 function Translate($Text, $Group = '') 21 { 22 if(array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != '')) 23 return($this->Data[$Group][$Text]); 24 24 else return($Text); 25 } 26 27 function TranslateReverse($Text, $Group = '') 28 { 29 $Key = array_search($Text, $this->Data[$Group]); 30 if(($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return($Text); 31 else return($Key); 25 32 } 26 33 } … … 232 239 } 233 240 234 // Short named global function235 function T($Text )241 // Short named global translation function 242 function T($Text, $Group = '') 236 243 { 237 244 global $GlobalLocaleManager; 238 245 239 if(isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text ));246 if(isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group)); 240 247 else return($Text); 241 248 } -
trunk/includes/Version.php
r842 r843 6 6 // and system will need database update. 7 7 8 $Revision = 84 2; // Subversion revision8 $Revision = 843; // Subversion revision 9 9 $DatabaseRevision = 811; // Database structure revision 10 $ReleaseTime = '2016-01-1 2';10 $ReleaseTime = '2016-01-14'; -
trunk/includes/system.php
r842 r843 9 9 var $OnPageNotFound; 10 10 var $Pages; 11 /* @var LocaleManager */ 12 var $LocaleManager; 11 13 12 14 function __construct() … … 23 25 function Init() 24 26 { 25 global $GlobalLocaleManager; 27 global $GlobalLocaleManager, $Config; 28 29 $this->Config = $Config; 30 date_default_timezone_set($this->Config['Web']['Timezone']); 26 31 27 32 $this->Database->Connect($this->Config['Database']['Host'], … … 55 60 } 56 61 } 57 $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode); 62 if(array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available)) 63 $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode); 58 64 59 65 $this->Menu = array … … 93 99 function Run() 94 100 { 95 global $ScriptStartTime, $TranslationTree, $StopAfterUpdateManager, $Config,101 global $ScriptStartTime, $TranslationTree, $StopAfterUpdateManager, 96 102 $UpdateManager, $DatabaseRevision; 97 103 98 $this->Config = $Config;99 104 $ScriptStartTime = GetMicrotime(); 100 101 105 if(GetRemoteAddress() != '') session_start(); 102 106 103 107 if(!isset($this->Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.'); 104 date_default_timezone_set($this->Config['Web']['Timezone']);105 108 106 109 $this->Init(); … … 181 184 } 182 185 186 function TranslateURL($URL, $Locale) 187 { 188 // Try translate URL directory parts from current locale to target locale 189 $Remaining = $URL; 190 $RemainingParts = explode('?', $Remaining); 191 $Directory = $RemainingParts[0]; 192 if(count($RemainingParts) > 1) 193 { 194 $Params = $RemainingParts[1]; 195 } else { 196 $Params = ''; 197 } 198 $TargetLocaleManager = new LocaleManager($this); 199 $TargetLocaleManager->Dir = $this->LocaleManager->Dir; 200 $TargetLocaleManager->Available = $this->LocaleManager->Available; 201 $TargetLocaleManager->LoadLocale($Locale); 202 203 $DirectoryParts = explode('/', $Directory); 204 foreach($DirectoryParts as $Index => $Item) 205 { 206 $NewText = $TargetLocaleManager->CurrentLocale->Texts->Translate($Item, 'URL'); 207 $DirectoryParts[$Index] = $NewText; 208 } 209 $Directory = implode('/', $DirectoryParts); 210 $Remaining = $Directory; 211 if($Params != '') $Remaining .= '?'.$Params; 212 213 return($Remaining); 214 } 215 216 function TranslateReverseURL($URL, $Locale) 217 { 218 // Try translate URL directory parts from current locale to target locale 219 $Remaining = $URL; 220 $RemainingParts = explode('?', $Remaining); 221 $Directory = $RemainingParts[0]; 222 if(count($RemainingParts) > 1) 223 { 224 $Params = $RemainingParts[1]; 225 } else { 226 $Params = ''; 227 } 228 $TargetLocaleManager = new LocaleManager($this); 229 $TargetLocaleManager->Dir = $this->LocaleManager->Dir; 230 $TargetLocaleManager->Available = $this->LocaleManager->Available; 231 $TargetLocaleManager->LoadLocale($Locale); 232 233 $DirectoryParts = explode('/', $Directory); 234 foreach($DirectoryParts as $Index => $Item) 235 { 236 $NewText = $TargetLocaleManager->CurrentLocale->Texts->TranslateReverse($Item, 'URL'); 237 $DirectoryParts[$Index] = $NewText; 238 } 239 $Directory = implode('/', $DirectoryParts); 240 $Remaining = $Directory; 241 if($Params != '') $Remaining .= '?'.$Params; 242 243 return($Remaining); 244 } 245 183 246 function LinkLocale($Target, $Locale = '') 184 247 { 185 248 if($Locale == '') $Locale = $this->LocaleManager->LangCode; 249 250 $Target = $this->TranslateURL($Target, $Locale); 251 186 252 if($Locale == $this->LocaleManager->DefaultLangCode) 187 253 return($this->Config['Web']['BaseURL'].$Target); … … 216 282 if(count($PathItems) == 0) $PathItems = array(''); 217 283 $PathItem = $PathItems[0]; 284 $PathItem = $this->LocaleManager->CurrentLocale->Texts->TranslateReverse($PathItem, 'URL'); 285 218 286 if(array_key_exists($PathItem, $Pages)) 219 287 { … … 286 354 if($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"'; 287 355 else $Selected = ''; 356 $Remaining = $this->System->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode); 357 288 358 $URL = $this->System->LinkLocale($Remaining, $Locale['Code']); 289 359 $Output .= '<option title="" value="'.$URL.'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>'; … … 306 376 //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>'; 307 377 $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'. 308 ' <a href="'.$this->System->Link('/user .php?user='.$this->System->User->Id).'">'.T('My page').'</a>'.309 ' <a href="'.$this->System->Link('/ Options.php').'">'.T('Options').'</a>'.378 ' <a href="'.$this->System->Link('/user/?user='.$this->System->User->Id).'">'.T('My page').'</a>'. 379 ' <a href="'.$this->System->Link('/options/').'">'.T('Options').'</a>'. 310 380 ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='. 311 381 $this->System->User->Id.'&group=0&state=2&text=&entry=').'">'.T('Translated').'</a>'. … … 317 387 { 318 388 $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a> '. 319 '<a href="'.$this->System->Link('/registrace.php').'">'.T('Registration').'</a>';389 '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>'; 320 390 } 321 391 $Output .= $this->ShowLocaleSelector();
Note:
See TracChangeset
for help on using the changeset viewer.