Changeset 618
- Timestamp:
- Dec 4, 2013, 12:39:55 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/Registration.php
r601 r618 19 19 20 20 $Output = '<form action="?" method="post"> 21 <fieldset><legend> Registrace nového uživatele</legend>21 <fieldset><legend>'.T('New user registration').'</legend> 22 22 <table> 23 23 <tr><td colspan="2">Pozorně si přečtěte <a href="info.php">pokyny k překladu</a> a řiďte se jimi. Překládat je nutno včetně háčků a čárek!<br/><br/></td></tr> -
trunk/admin/index.php
r610 r618 92 92 function ShowLocale() 93 93 { 94 global $Locale , $System;94 global $LocaleManager, $System; 95 95 96 $Locale->AnalyzeCode(dirname(dirname(__FILE__))); 97 $Locale->UpdateToDatabase($System->Database, $Locale->Texts->Code); 98 $FileName = dirname(dirname(__FILE__)).'/locale/'.$Locale->Texts->Code.'.php'; 99 $Locale->SaveToFile($FileName); 96 $LocaleManager->UpdateAll(dirname(dirname(__FILE__))); 100 97 $Output = 'Překlad rozhraní přegenerován'; 101 98 $Output .= '<table class="BaseTable"><tr><th>Originál</th><th>Překlad</th></tr>'; 102 foreach($Locale ->Texts->Data as $Index => $Item)99 foreach($LocaleManager->CurrentLocale->Texts->Data as $Index => $Item) 103 100 $Output .= '<tr><td>'.$Index.'</td><td>'.$Item.'</td></tr>'; 104 101 $Output .= '</table>'; 105 $Output .= 'Překladov á soubor '.$FileName.' zaktualizován';102 $Output .= 'Překladové soubory zaktualizovány'; 106 103 return($Output); 107 104 } -
trunk/includes/Locale.php
r610 r618 5 5 var $Data; 6 6 var $Code; 7 var $Title; 7 8 8 9 function __construct() … … 10 11 $this->Data = array(); 11 12 $this->Code = 'en'; 13 $this->Title = 'English'; 12 14 } 13 15 … … 15 17 { 16 18 } 19 20 function Translate($Text) 21 { 22 if(array_key_exists($Text, $this->Data) and ($this->Data[$Text] != '')) 23 return($this->Data[$Text]); 24 else return($Text); 25 } 17 26 } 18 27 … … 22 31 var $Dir; 23 32 24 function __construct() 25 { 33 function __construct($System) 34 { 35 parent::__construct($System); 26 36 $this->Texts = new LocaleText(); 27 }28 29 function Translate($Text)30 {31 if(array_key_exists($Text, $this->Texts->Data) and ($this->Texts->Data[$Text] != ''))32 return($this->Texts->Data[$Text]);33 else return($Text);34 37 } 35 38 … … 41 44 $ClassName = 'LocaleText'.$Language; 42 45 $this->Texts = new $ClassName(); 43 } else $this->Texts = new LocaleText();46 } else throw new Exception('Language file '.$FileName.' not found'); 44 47 $this->Texts->Load(); 45 48 } … … 97 100 ' {'."\n". 98 101 ' $this->Code = \''.$this->Texts->Code.'\';'."\n". 102 ' $this->Title = \''.$this->Texts->Title.'\';'."\n". 99 103 ' $this->Data = array('."\n"; 100 104 foreach($this->Texts->Data as $Index => $Item) … … 153 157 } 154 158 155 $Locale = new Locale(); 159 class LocaleManager extends Model 160 { 161 var $CurrentLocale; 162 var $Codes; 163 var $Dir; 164 165 function __construct($System) 166 { 167 parent::__construct($System); 168 $this->Codes = array('en'); 169 $this->CurrentLocale = new Locale($System); 170 } 171 172 function LoadAvailable() 173 { 174 $this->Available = array(); 175 $FileList = scandir($this->Dir); 176 foreach($FileList as $FileName) 177 { 178 if(substr($FileName, -4) == '.php') 179 { 180 $Code = substr($FileName, 0, -4); 181 $Locale = new Locale($this->System); 182 $Locale->Dir = $this->Dir; 183 $Locale->Load($Code); 184 $this->Available['Code'] = array('Code' => $Code, 'Title' => $Locale->Texts->Title); 185 } 186 } 187 } 188 189 function UpdateAll($Directory) 190 { 191 $Locale = new Locale($this->System); 192 $Locale->AnalyzeCode($Directory); 193 $FileList = scandir($this->Dir); 194 foreach($FileList as $FileName) 195 { 196 if(substr($FileName, -4) == '.php') 197 { 198 $FileLocale = new Locale($this->System); 199 $FileLocale->Dir = $this->Dir; 200 $FileLocale->Load(substr($FileName, 0, -4)); 201 202 // Add new 203 foreach($Locale->Texts->Data as $Index => $Item) 204 if(!array_key_exists($Index, $FileLocale->Texts->Data)) 205 $FileLocale->Texts->Data[$Index] = $Item; 206 // Remove old 207 foreach($FileLocale->Texts->Data as $Index => $Item) 208 if(!array_key_exists($Index, $Locale->Texts->Data)) 209 unset($FileLocale->Texts->Data[$Index]); 210 $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code); 211 $FileName = $this->Dir.'/'.$FileLocale->Texts->Code.'.php'; 212 $FileLocale->SaveToFile($FileName); 213 } 214 } 215 $this->CurrentLocale->Load($this->CurrentLocale->Texts->Code); 216 } 217 218 function LoadLocale($Code) 219 { 220 $this->CurrentLocale->Dir = $this->Dir; 221 $this->CurrentLocale->Load($Code); 222 } 223 } 156 224 157 225 // Short named global function 158 226 function T($Text) 159 227 { 160 global $Locale; 161 162 return($Locale->Translate($Text)); 163 } 228 global $LocaleManager; 229 230 if(isset($LocaleManager)) return($LocaleManager->CurrentLocale->Texts->Translate($Text)); 231 else return($Text); 232 } -
trunk/includes/Version.php
r615 r618 6 6 // and system will need database update. 7 7 8 $Revision = 61 5; // Subversion revision8 $Revision = 618; // Subversion revision 9 9 $DatabaseRevision = 610; // Database structure revision 10 $ReleaseTime = '2013-1 1-27';10 $ReleaseTime = '2013-12-04'; -
trunk/includes/global.php
r615 r618 11 11 include_once(dirname(__FILE__).'/AppModule.php'); 12 12 include_once(dirname(__FILE__).'/Locale.php'); 13 $Locale = new Locale();14 $Locale->Dir = dirname(__FILE__).'/../locale';15 $Locale->Load($Config['Web']['Locale']);16 13 17 14 // Include application modules -
trunk/includes/system.php
r610 r618 23 23 function Init() 24 24 { 25 global $Config ;25 global $Config, $LocaleManager; 26 26 27 27 $this->Config = $Config; … … 35 35 //$this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery']; 36 36 $this->ModuleManager = new AppModuleManager(); 37 37 38 $this->PathItems = ProcessURL(); 39 // Initialize locale 40 $LocaleManager = new LocaleManager($this); 41 $LocaleManager->Dir = dirname(dirname(__FILE__)).'/locale'; 42 $LocaleManager->Available = array( 43 'cs' => array('Code' => 'cs', 'Title' => 'Česky'), 44 'en' => array('Code' => 'en', 'Title' => 'English'), 45 ); 46 $Code = $Config['Web']['Locale']; 47 if(array_key_exists('Locale', $_SESSION)) $Code = $_SESSION['Locale']; 48 if(array_key_exists('locale', $_GET)) $Code = $_GET['locale']; 49 //echo(phpinfo()); 50 if(!array_key_exists($Code, $LocaleManager->Available)) $Code = 'en'; 51 $_SESSION['Locale'] = $Code; 52 $LocaleManager->LoadLocale($Code); 53 38 54 $this->Menu = array 39 55 ( … … 141 157 if($this->DoNotShowPage == false) 142 158 { 143 $this->PathItems = ProcessURL();144 159 $this->ShowPage(); 145 160 } … … 229 244 function ShowTopBar() 230 245 { 246 global $LocaleManager; 247 231 248 $Output = '<div class="Menu">'; 232 249 if(!$this->System->User->Licence(LICENCE_USER)) 233 250 $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>'; 234 $Output .= '<span class="MenuItem"></span> ';251 $Output .= '<span class="MenuItem"></span><span class="MenuItem2">'; 235 252 if($this->System->User->Licence(LICENCE_USER)) 236 253 { … … 238 255 //$Team = $DbResult->fetch_assoc(); 239 256 //$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>'; 240 $Output .= '<span class="MenuItem2">'.$this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.257 $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'. 241 258 ' <a href="'.$this->System->Link('/user.php?user='.$this->System->User->Id).'">'.T('My page').'</a>'. 242 259 ' <a href="'.$this->System->Link('/Options.php').'">'.T('Options').'</a>'. … … 245 262 ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='. 246 263 $this->System->User->Id.'&group=0&state=3&text=&entry=').'">'.T('Unfinished').'</a>'. 247 ' <a title="Nikým nepřeložené texty" href="'. $this->System->Link('/TranslationList.php?user=0&group=0&state=1&text=&entry=').'">'.T('Untranslated').'</a>'.248 '</span>';264 ' <a title="Nikým nepřeložené texty" href="'. 265 $this->System->Link('/TranslationList.php?user=0&group=0&state=1&text=&entry=').'">'.T('Untranslated').'</a>'; 249 266 } else 250 267 { 251 $Output .= '< span class="MenuItem2"><form action="'.$this->System->Link('/?action=login').'" method="post"> '.268 $Output .= '<form action="'.$this->System->Link('/?action=login').'" method="post"> '. 252 269 'Jméno: <input type="text" name="LoginUser" size="8 " /> '. 253 270 'Heslo: <td><input type="password" name="LoginPass" size="8" /> '. 254 271 '<input type="submit" value="'.T('Login').'" /></form> '. 255 '<a href="'.$this->System->Link('/registrace.php').'">'.T('Registration').'</a> </span>';272 '<a href="'.$this->System->Link('/registrace.php').'">'.T('Registration').'</a>'; 256 273 } 257 $Output .= '</div>'; 274 $Output .= ' <form action="?setlocale" method="get">'; 275 $Output .= '<select onchange="window.location=\'?locale=\'+this.value">'; 276 foreach($LocaleManager->Available as $Locale) 277 { 278 if($Locale['Code'] == $LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"'; 279 else $Selected = ''; 280 $Output .= '<option title="" value="'.$Locale['Code'].'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>'; 281 } 282 $Output .= '</select><noscript><input type="submit" value="Submit"></noscript></form>'; 283 $Output .= '</span></div>'; 258 284 return($Output); 259 285 } -
trunk/locale/cs.php
r610 r618 6 6 { 7 7 $this->Code = 'cs'; 8 $this->Title = 'Česky'; 8 9 $this->Data = array( 9 10 'Access denied' => 'Nemáte oprávnění', … … 44 45 'Search' => 'Vyhledávání', 45 46 'Do search' => 'Hledat', 47 'New user registration' => 'Registrace nového uživatele', 46 48 ); 47 49 } -
trunk/locale/en.php
r610 r618 6 6 { 7 7 $this->Code = 'en'; 8 $this->Title = 'English'; 8 9 $this->Data = array( 9 10 'Access denied' => '', … … 16 17 'All news' => '', 17 18 'Add' => '', 18 'Message was sent.' => '',19 19 'Registration' => '', 20 20 'Menu' => '', 21 'Incorrect name or password' => '', 22 'Login successful. Welcome <strong>%s</strong>!' => '', 23 'User name or password was not entered' => '', 24 'Servers' => '', 25 'Message was sent' => '', 26 'New user registration' => '', 27 'Online translators' => '', 28 'Files' => '', 29 'Instructions' => '', 30 'Data source' => '', 31 'Presentation' => '', 32 'IRC chat' => '', 33 'Administration' => '', 34 'Page "%s" not found' => '', 35 'Logout' => '', 36 'My page' => '', 37 'Options' => '', 38 'Translated' => '', 39 'Unfinished' => '', 40 'Untranslated' => '', 41 'Login' => '', 42 'Search' => '', 43 'Do search' => '', 44 'Translate groups' => '', 45 'Version' => '', 46 'Source code' => '', 47 'Changelog' => '', 21 48 ); 22 49 }
Note:
See TracChangeset
for help on using the changeset viewer.