Ignore:
Timestamp:
Jan 14, 2016, 10:25:47 PM (9 years ago)
Author:
chronos
Message:
  • Added: Support for translatable URLs. Now each language can have URL in its language.

This requires to all links inside web to use System->Link function which is responsible for translation.
All links need to be written in english so they can be translated to other language.

Location:
trunk/Modules/Translation
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Translation/Form.php

    r836 r843  
    9191
    9292          if(($Line['Language'] <> 0) and ($LineUser['Name'] <> ''))
    93             $Output .= 'Přeložil: <a href="'.$this->System->Link('/user.php?user='.$Line['User']).'"><strong>'.$LineUser['Name'].'</strong></a> dne '.HumanDate($Line['ModifyTime']).'<br />';
     93            $Output .= 'Přeložil: <a href="'.$this->System->Link('/user/?user='.$Line['User']).'"><strong>'.$LineUser['Name'].'</strong></a> dne '.HumanDate($Line['ModifyTime']).'<br />';
    9494          if(($Line['Take'] <> 0) and ($Line['Take'] <> $Line['ID']))
    9595          {
  • trunk/Modules/Translation/LoadNames.php

    r816 r843  
    1515    } else {
    1616      $Text = str_replace(' '.$orig,' <span Title="Přelož jako:&nbsp;'.$tran_replace.
    17         '" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/dictionary/?search='.$tran).'">'.$orig_replace.'</a></span>',$Text);
     17        '" class="edit"><a class="edit" target="_NEW2" href="'.$this->System->Link('/'.T('dictionary', 'URL').'/?search='.$tran).'">'.$orig_replace.'</a></span>',$Text);
    1818    }
    1919  //   }
  • trunk/Modules/Translation/Translation.php

    r842 r843  
    3030    $this->System->RegisterPage('save.php', 'PageTranslationSave');
    3131    $this->System->RegisterPage('progress', 'PageProgress');
     32    $this->System->RegisterPage('translation-groups', 'PageTranslationGroups');
    3233    $this->System->RegisterPage('TranslationList.php', 'PageTranslationList');
    3334    $this->System->RegisterPage('LoadNames.php', 'PageLoadNames');
     
    4445      'Title' => T('Data source'),
    4546      'Hint' => 'Informace o překladových skupinách',
    46       'Link' => $this->System->Link('/TranslationList.php?action=grouplist'),
     47      'Link' => $this->System->Link('/translation-groups/'),
    4748      'Permission' => LICENCE_ANONYMOUS,
    4849      'Icon' => '',
  • trunk/Modules/Translation/TranslationList.php

    r842 r843  
    2424    $Output = '<form action="?" method="post">'.
    2525        '<table class="BaseTable"><tr>'.
    26         '<th>Zpracování</th>'.
    27         '<th>Skupina</th>'.
    28         '<th>Verze</th>'.
    29         '<th>Jazyk</th>'.
    30         '<th>Překladatel</th>'.
    31         '<th>Slova</th>'.
    32         '<th>Položka</th>'.
     26        '<th>'.T('Processing').'</th>'.
     27        '<th>'.T('Group').'</th>'.
     28        '<th>'.T('Version').'</th>'.
     29        '<th>'.T('Language').'</th>'.
     30        '<th>'.T('Translator').'</th>'.
     31        '<th>'.T('Words').'</th>'.
     32        '<th>'.T('Item').'</th>'.
    3333        '<th></th></tr><tr>';
    3434
     
    3737    $Output .= '<td><select name="state">';
    3838    $StateTypes = array(
    39       CompletionState::All => 'Všechny',
    40       CompletionState::NotTranslated => 'Nepřeložené',
    41       CompletionState::Translated => 'Přeložené',
    42       CompletionState::NotFinished => 'Rozpracované',
    43       CompletionState::Original => 'Anglické',
    44       CompletionState::NotFinishedNotTranslated => 'Rozpracované-Nepřeložené',
    45       CompletionState::Missing1 => 'Chybějící $ ($N,$s..)',
    46       CompletionState::Missing2 => 'Chybějící $-Neopravený'
     39      CompletionState::All => T('All'),
     40      CompletionState::NotTranslated => T('Not translated'),
     41      CompletionState::Translated => T('Translated'),
     42      CompletionState::NotFinished => T('Unfinished'),
     43      CompletionState::Original => T('Original'),
     44      CompletionState::NotFinishedNotTranslated => T('Unfinished - Not translated'),
     45      CompletionState::Missing1 => T('Missing $ ($N,$s..)'),
     46      CompletionState::Missing2 => T('Missing $ - Not fixed'),
    4747    );
    48     foreach ($StateTypes as $index=>$StateType) {
     48    foreach ($StateTypes as $index => $StateType) {
    4949      if($Filter['State'] == $index) $Selected = ' selected="selected"';
    5050      else $Selected = '';
     
    7171    if($Filter['Group'] == 0) $Selected = ' selected="selected"';
    7272    else $Selected = '';
    73     $Output .= '<option value="0"'.$Selected.'>Všechny</option>';
     73    $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
    7474    $DbResult = $this->Database->query('SELECT `Id`,`Name` FROM `Group` ORDER BY `Name`');
    7575    while($Group = $DbResult->fetch_assoc())
     
    9797    if($Filter['Version'] == 0) $Selected = ' selected="selected"';
    9898    else $Selected = '';
    99     $Output .= '<option value="0"'.$Selected.'>Všechny</option>';
     99    $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
    100100    $DbResult = $this->Database->query('SELECT `Id`, `BuildNumber`,`Version` FROM `ClientVersion` WHERE `Imported` = 1 ORDER BY `BuildNumber` DESC');
    101101    while($Version = $DbResult->fetch_assoc())
     
    136136    if($Filter['User'] == 0) $Selected = ' selected="selected"';
    137137    else $Selected = '';
    138     $Output .= '<option value="0"'.$Selected.'>Všichni</option>';
     138    $Output .= '<option value="0"'.$Selected.'>'.T('All').'</option>';
    139139    $DbResult = $this->Database->query('SELECT `Id`, `Name` FROM `User` ORDER BY `Name`');
    140140    while($User = $DbResult->fetch_assoc())
     
    238238    */
    239239
    240     $Output .= '<td><input type="submit" value="Filtrovat"/></td>';
     240    $Output .= '<td><input type="submit" value="'.T('Filter').'"/></td>';
    241241    $Output .= '</tr></table>';
    242242    $Output .= '</form><br/>';
     
    270270    $Output .= $PageList['Output'];
    271271    $TableColumns = array(
    272         array('Name' => 'ID', 'Title' => 'Číslo'),
    273         array('Name' => 'Entry', 'Title' => 'Položka'),
    274         array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => 'Název'),
    275         array('Name' => 'VersionStart', 'Title' => 'Verze od'),
    276         array('Name' => 'VersionEnd', 'Title' => 'Verze do'),
    277         array('Name' => 'LanguageName', 'Title' => 'Jazyk'),
    278         array('Name' => 'UserName', 'Title' => 'Překladatel'),
    279         array('Name' => 'ModifyTime', 'Title' => 'Datum'),
     272        array('Name' => 'ID', 'Title' => T('Number')),
     273        array('Name' => 'Entry', 'Title' => T('Item')),
     274        array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => T('Name')),
     275        array('Name' => 'VersionStart', 'Title' => T('From version')),
     276        array('Name' => 'VersionEnd', 'Title' => T('To version')),
     277        array('Name' => 'LanguageName', 'Title' => T('Language')),
     278        array('Name' => 'UserName', 'Title' => T('Translator')),
     279        array('Name' => 'ModifyTime', 'Title' => T('Date')),
    280280    );
    281281
     
    295295          GetVersionWOWId($Line['VersionEnd'])).'">'.GetVersionWOW($Line['VersionEnd']).'</a></td>'.
    296296        '<td>'.$Line['LanguageName'].'</td>'.
    297         '<td><a href="user.php?user='.$Line['UserId'].'">'.$Line['UserName'].'</a></td>'.
     297        '<td><a href="'.$this->System->Link('/user/?user='.$Line['UserId']).'">'.$Line['UserName'].'</a></td>'.
    298298        '<td>'.HumanDate($Line['ModifyTime']).'</td>'.
    299299        '</tr>';
     
    310310    $Output = $Filter['Output'];
    311311
    312     $Output .= '<table class="BaseTable"><tr><th>Skupina</th><th>Počet</th></tr>';
     312    $Output .= '<table class="BaseTable"><tr><th>'.T('Group').'</th><th>'.T('Count').'</th></tr>';
    313313    $Total = 0;
    314314    foreach($TranslationTree as $Group)
     
    322322        $Total += $Line[0];
    323323      }
    324       $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Total.'</strong></td></tr>'.
     324      $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Total.'</strong></td></tr>'.
    325325          '</table>';
    326326      return($Output);
    327   }
    328 
    329   function ShowGroupTypeList()
    330   {
    331     $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`');
    332     $DbRow = $DbResult->fetch_row();
    333     $PageList = GetPageList($DbRow[0]);
    334     $Output = '<h3>'.T('List of translation groups').'</h3>'.
    335         $PageList['Output'];
    336 
    337     $Output .= '<table class="BaseTable">';
    338     $TableColumns = array(
    339         array('Name' => 'Name', 'Title' => T('Name')),
    340         array('Name' => 'SourceType', 'Title' => T('Source type')),
    341         array('Name' => '', 'Title' => T('Sources')),
    342         array('Name' => 'LastImport', 'Title' => T('Date of last import')),
    343         array('Name' => 'LastVersion', 'Title' => T('Version of last import')),
    344     );
    345     if($this->System->User->Licence(LICENCE_ADMIN))
    346       $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
    347 
    348     $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
    349     $Output .= $Order['Output'];
    350 
    351     $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
    352     while($Group = $DbResult->fetch_assoc())
    353     {
    354       $Output .= '<tr><td><a href="?group='.$Group['Id'].'&amp;action=filter">'.$Group['Name'].'</a></td>'.
    355       '<td>'.$Group['SourceType'].'</td><td>';
    356       if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
    357       if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
    358       if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
    359       $Output .= '</td>';
    360       if($this->System->User->Licence(LICENCE_ADMIN))
    361         $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
    362           $Group['Id'].'&amp;type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
    363         else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
    364       $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
    365         GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
    366       if($this->System->User->Licence(LICENCE_ADMIN))
    367         $Output .= '<td><a href="?action=groupdelete&amp;id='.$Group['Id'].'">'.T('Remove').'</a></td>';
    368       $Output .= '</tr>';
    369 
    370     }
    371     $Output .= '</table>'.
    372         '<br /><a title="'.T('Changelog of changes after import').'" href="'.$this->System->Link('/log/?type=11').'">'.T('Changelog of text modification during import').'</a><br/>';
    373     if($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
    374     return($Output);
    375327  }
    376328
     
    417369      $Output .= '</table>';
    418370    }
     371    return($Output);
     372  }
     373
     374  function Show()
     375  {
     376    $this->Title = T('Translation groups');
     377    $Action = GetParameter('action', '');
     378    if($Action == 'filter') $Output = $this->ShowMenu();
     379    else
     380    {
     381      $Filter = $this->ShowFilter();
     382      if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter);
     383      else $Output = $this->ShowGroupList($Filter);
     384    }
     385    return($Output);
     386  }
     387}
     388
     389class PageTranslationGroups extends Page
     390{
     391  function ShowList()
     392  {
     393    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`');
     394    $DbRow = $DbResult->fetch_row();
     395    $PageList = GetPageList($DbRow[0]);
     396    $Output = '<h3>'.T('List of translation groups').'</h3>'.
     397    $PageList['Output'];
     398
     399    $Output .= '<table class="BaseTable">';
     400    $TableColumns = array(
     401      array('Name' => 'Name', 'Title' => T('Name')),
     402      array('Name' => 'SourceType', 'Title' => T('Source type')),
     403      array('Name' => '', 'Title' => T('Sources')),
     404      array('Name' => 'LastImport', 'Title' => T('Date of last import')),
     405      array('Name' => 'LastVersion', 'Title' => T('Version of last import')),
     406   );
     407   if($this->System->User->Licence(LICENCE_ADMIN))
     408   $TableColumns[] = array('Name' => '', 'Title' => T('Actions'));
     409
     410   $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
     411   $Output .= $Order['Output'];
     412
     413   $DbResult = $this->Database->query('SELECT * FROM `Group`'.$Order['SQL'].$PageList['SQLLimit']);
     414   while($Group = $DbResult->fetch_assoc())
     415   {
     416     $Output .= '<tr><td><a href="?group='.$Group['Id'].'&amp;action=filter">'.$Group['Name'].'</a></td>'.
     417       '<td>'.$Group['SourceType'].'</td><td>';
     418     if($Group['MangosTable'] != '') $Output .= $Group['MangosTable'].'.sql ';
     419     if($Group['DBCFileName'] != '') $Output .= $Group['DBCFileName'].'.dbc ';
     420     if($Group['LuaFileName'] != '') $Output .= $Group['LuaFileName'].'.lua ';
     421     $Output .= '</td>';
     422     if($this->System->User->Licence(LICENCE_ADMIN))
     423       $Output .= '<td><a title="Změny po posledním importu u vybrané překladové skupiny" href="'.$this->System->Link('/log/?group='.
     424     $Group['Id'].'&amp;type=11').'">'.HumanDate($Group['LastImport']).'</a></td>';
     425       else $Output .= '<td>'.HumanDate($Group['LastImport']).'</td>';
     426     $Output .= '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
     427       GetVersionWOWId($Group['LastVersion'])).'">'.GetVersionWOW($Group['LastVersion']).'</a></td>';
     428     if($this->System->User->Licence(LICENCE_ADMIN))
     429       $Output .= '<td><a href="?action=groupdelete&amp;id='.$Group['Id'].'">'.T('Remove').'</a></td>';
     430     $Output .= '</tr>';
     431    }
     432    $Output .= '</table>'.
     433      '<br /><a title="'.T('Changelog of changes after import').'" href="'.$this->System->Link('/log/?type=11').'">'.T('Changelog of text modification during import').'</a><br/>';
     434    if($this->System->User->Licence(LICENCE_ADMIN)) $Output .= '<a href="?action=groupadd">'.T('Add translation group').'</a>';
    419435    return($Output);
    420436  }
     
    478494    $Output = ShowMessage('Překladová skupina vytvořena', MESSAGE_INFORMATION);
    479495      } else $Output = ShowMessage('Překladová skupina '.$TableName.' již existuje', MESSAGE_CRITICAL);
    480       $Output .= $this->ShowGroupTypeList();
     496      $Output .= $this->ShowList();
    481497    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    482498    return($Output);
     
    497513      } else $Output = ShowMessage('Překladová skupina nenalezena', MESSAGE_CRITICAL);
    498514    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    499     $Output .= $this->ShowGroupTypeList();
     515    $Output .= $this->ShowList();
    500516    return($Output);
    501517  }
     
    506522    $Action = GetParameter('action', '');
    507523    if($Action == 'filter') $Output = $this->ShowMenu();
    508     else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList();
    509524    else if($Action == 'groupadd') $Output = $this->ShowGroupAdd();
    510525    else if($Action == 'groupdelete') $Output = $this->ShowGroupDelete();
    511526    else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish();
    512     else
    513     {
    514       $Filter = $this->ShowFilter();
    515       if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter);
    516       else $Output = $this->ShowGroupList($Filter);
    517     }
     527    else $Output = $this->ShowList();
    518528    return($Output);
    519529  }
Note: See TracChangeset for help on using the changeset viewer.