Changeset 133

Show
Ignore:
Timestamp:
08/29/07 22:09:49 (17 months ago)
Author:
chris
Message:

Added localisation support using GNU Gettext

Location:
trunk
Files:
17 added
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGELOG

    r131 r133  
    2222* Made sorting take advantage of the multi-call support, speeding up queue 
    2323  sorting significantly. 
     24 
     25* Added gettext multi-language support. For information on translating 
     26  HellaWorld to your language, please see the GNU Gettext documentation. 
     27 
     28* Added partial translation into Dutch (Thanks Stevuu) 
     29 
     30* Added partial translation into Swedish (Thanks Toxik) 
    2431 
    25321.7 
  • trunk/README

    r131 r133  
    88Then upload and view the site within your web browser. That should 
    99be all that's necessary. 
     10 
     11*Supported Languages* 
     12 
     13Multiple languages are supported using GNU Gettext. Language codes are 
     14in the form of lang_COUNTRY, so en_GB for English or sv_SE for Swedish. 
     15 
     16Language codes with translations available are: 
     17en_GB - English (Default) 
     18en_US - American English 
     19nl_NL - Dutch 
     20sv_SE - Swedish 
     21 
     22If you would like to translate HellaWorld into your native language, 
     23please read the GNU Gettext documentation, the standard English messages 
     24are located in locale/en_GB.UTF-8/messages.po 
    1025 
    1126*Tracking Finished Items* 
  • trunk/config-sample.php

    r131 r133  
    1616                'password'              =>      'changeme',             // The password specified in hellanzb.conf 
    1717                'showfinished'  =>      true,                   // Show finished items, see README for details 
     18                'language'              =>      'en_GB',                // The language code HellaWorld should use 
    1819        ); 
    1920 
  • trunk/index.php

    r131 r133  
    4848                } 
    4949 
     50                if (!function_exists('_')) { 
     51                        function _($string) { 
     52                                return $string; 
     53                        } 
     54                } else { 
     55                        putenv('LC_ALL=' . $config['language'] . '.UTF-8'); 
     56                        setlocale(LC_ALL, $config['language'] . '.UTF-8'); 
     57                        bindtextdomain('messages', 'locale'); 
     58                        textdomain('messages'); 
     59                } 
     60 
    5061                $hellaworldversion = "1.8-SVN"; 
    5162                $protocol = (($_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http'); 
     
    5970                                header('WWW-Authenticate: Basic realm="HellaWorld"'); 
    6071                                header('HTTP/1.0 401 Unauthorized'); 
    61                                 throw new Exception('Unauthorized access'); 
     72                                throw new Exception(_('Unauthorized access')); 
    6273                        } else { 
    6374                                $config['username'] = $_SERVER['PHP_AUTH_USER']; 
     
    7283                                                header('WWW-Authenticate: Basic realm="HellaWorld"'); 
    7384                                                header('HTTP/1.0 401 Unauthorized'); 
    74                                                 throw new Exception('Unauthorized access'); 
     85                                                throw new Exception(_('Unauthorized access')); 
    7586                                        } else { 
    7687                                                $_SESSION['login'] = 0; 
    7788                                                header('HTTP/1.0 403 Forbidden'); 
    78                                                 throw new Exception('Access Forbidden'); 
     89                                                throw new Exception(_('Access Forbidden')); 
    7990                                        } 
    8091                                } else { 
     
    266277                                        $fp = @fopen('completed.xml', 'w'); 
    267278                                        if (!$fp) { 
    268                                                 throw new Exception('Unable to write to completed.xml, please check permissions'); 
     279                                                throw new Exception(_('Unable to write to completed.xml, please check permissions')); 
    269280                                        } 
    270281                                        fwrite($fp, $x->asXML()); 
     
    281292                                $fp = @fopen('completed.xml', 'w'); 
    282293                                if (!$fp) { 
    283                                         throw new Exception('Unable to write to completed.xml, please check permissions'); 
     294                                        throw new Exception(_('Unable to write to completed.xml, please check permissions')); 
    284295                                } 
    285296                                fwrite($fp, $x->asXML()); 
     
    287298                                header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . $self); 
    288299                        } else { 
    289                                 throw new Exception('Invalid ID provided'); 
     300                                throw new Exception(_('Invalid ID provided')); 
    290301                        } 
    291302                } 
  • trunk/templates/default.php

    r132 r133  
    6060                        <h1>HellaWorld</h1> 
    6161                        <div> 
    62                                 <p>HellaNZB v<?php echo $c->version; ?> - Uptime: <?php echo $c->uptime; ?></p> 
    63                                 <p>Downloaded: <?php echo $c->totalFiles; ?> files in <?php echo $c->totalSegments; ?> segments totalling <?php echo $c->totalMB; ?>MB via <?php echo $c->totalNZBs; ?> NZB files</p> 
     62                                <p><?php printf(_('HellaNZB %s - Uptime: %s'), $c->version, $c->uptime); ?></p> 
     63                                <p><?php printf(_('Downloaded: %s files in %s segments totalling %sMB via %s NZB files'), $c->totalfiles, $c->totalSegments, $c->totalMB, $c->totalNZBz); ?></p> 
    6464                        </div> 
    6565                </div> 
    6666                <div id="container"> 
    6767                        <div id="modules"> 
    68                                 <h2>Add NZB Via Newzbin ID Or URL</h2> 
     68                                <h2><?php echo _('Add NZB Via Newzbin ID Or URL'); ?></h2> 
    6969                                <div> 
    7070                                        <form method="get" action="<?php echo $self; ?>"> 
    7171                                                <fieldset> 
    7272                                                        <input type="submit" value="Go" style="float:right;" /> 
    73                                                         <label for="nzbdownload">Article ID or URL: <input type="text" name="nzbdownload" id="nzbdownload" /></label> 
     73                                                        <label for="nzbdownload"><?php echo _('Article ID or URL:'); ?> <input type="text" name="nzbdownload" id="nzbdownload" /></label> 
    7474                                                </fieldset> 
    7575                                        </form> 
    7676                                </div> 
    77                                 <h2>Set Rate Limit</h2> 
     77                                <h2><?php echo _('Set Rate Limit'); ?></h2> 
    7878                                <div> 
    7979                                        <form method="get" action="<?php echo $self; ?>"> 
    8080                                                <fieldset> 
    8181                                                        <input type="submit" value="Go" style="float:right" /> 
    82                                                         <label for="maxrate">Limit (KB/s): <input type="text" name="maxrate" id="maxrate" value="<?php echo $c->rateLimit; ?>" /></label> 
     82                                                        <label for="maxrate"><?php echo _('Limit (KB/s):'); ?> <input type="text" name="maxrate" id="maxrate" value="<?php echo $c->rateLimit; ?>" /></label> 
    8383                                                </fieldset> 
    8484                                        </form> 
     
    8989                                        <ul> 
    9090                                        <?php if ($c->paused): ?> 
    91                                                 <li><a href="<?php echo $self; ?>?action=8" title="Resume">Resume downloading</a></li> 
     91                                                <li><a href="<?php echo $self; ?>?action=8" title="<?php echo _('Resume downloading'); ?>"><?php echo _('Resume downloading'); ?></a></li> 
    9292                                        <?php else: ?> 
    93                                                 <li><a href="<?php echo $self; ?>?action=7" title="Pause">Pause current download</a></li> 
     93                                                <li><a href="<?php echo $self; ?>?action=7" title="<?php echo _('Pause current download'); ?>"><?php echo _('Pause current download'); ?></a></li> 
    9494                                        <?php endif; ?> 
    95                                                 <li><a href="<?php echo $self; ?>?action=9" title="Cancel" onclick="return confirm('This will cancel the current download and remove it from the queue, continue?');">Cancel current download</a></li> 
    96                                                 <li><a href="<?php echo $self; ?>?action=11" title="Shut down" onclick="return confirm('HellaNZB cannot be restarted without shell access, continue?');">Shut down HellaNZB</a></li> 
    97                                                 <li><a href="<?php echo $self; ?>?action=10" title="Clear queue" onclick="return confirm('This cannot be undone, continue?');">Clear the queue</a></li> 
     95                                                <li><a href="<?php echo $self; ?>?action=9" title="<?php echo _('Cancel current download'); ?>" onclick="return confirm('<?php echo _('This will cancel the current download and remove it from the queue, continue?'); ?>');"><?php echo _('Cancel current download'); ?></a></li> 
     96                                                <li><a href="<?php echo $self; ?>?action=11" title="<?php echo _('Shut down HellaNZB'); ?>" onclick="return confirm('<?php echo _('HellaNZB cannot be restarted without shell access, continue?'); ?>');"><?php echo _('Shut down HellaNZB'); ?></a></li> 
     97                                                <li><a href="<?php echo $self; ?>?action=10" title="<?php echo _('Clear the queue'); ?>" onclick="return confirm('<?php echo _('This cannot be undone, continue?'); ?>');"><?php echo _('Clear the queue'); ?></a></li> 
    9898                                        </ul> 
    9999                                </div> 
    100100                                <div id="info"> 
    101 <h2>Currently Downloading</h2> 
     101<h2><?php echo _('Currently Downloading'); ?></h2> 
    102102<?php if ($c->downloadCount > 0): foreach($c->downloads as $download): ?> 
    103103<div><?php echo htmlspecialchars($download['nzbName']); ?></div> 
    104 <div class="queuestats"><img src="progress.php?percentage=<?php echo $c->completed; ?>" alt="progress bar" /> <?php echo $c->completed; ?>% complete</div> 
    105 <div class="queuestats"><?php echo $c->remaining; ?>MB of <?php echo $download['total_mb']; ?>MB remaining</div> 
    106 <div class="queuestats" style="margin-bottom: 5px;"><?php echo ((!$c->paused) ? 'ETA ' . $c->formatTimeStamp($c->eta) . ' at ' . $c->transferRate . 'KB/s' : 'PAUSED'); ?></div> 
     104<div class="queuestats"><img src="progress.php?percentage=<?php echo $c->completed; ?>" alt="progress bar" /> <?php printf(_('%s%% complete'), $c->completed); ?></div> 
     105<div class="queuestats"><?php printf(_('%sMB of %sMB remaining'), $c->remaining, $download['total_mb']); ?></div> 
     106<div class="queuestats" style="margin-bottom: 5px;"><?php if (!$c->paused): printf(_('ETA %s at %sKB/s'), $c->formatTimeStamp($c->eta), $c->transferRate); else: echo _('PAUSED'); endif; ?></div> 
    107107<?php endforeach; else: ?> 
    108 <div style="margin-bottom: 5px;">Nothing</div> 
     108<div style="margin-bottom: 5px;"><?php echo _('Nothing'); ?></div> 
    109109<?php endif; ?> 
    110 <h2>Currently Processing</h2> 
     110<h2><?php echo _('Currently Processing'); ?></h2> 
    111111<?php if ($c->processCount > 0): foreach($c->processing as $processing): ?> 
    112112<div><?php echo htmlspecialchars($processing); ?></div> 
    113113<?php endforeach; else: ?> 
    114 <div>Nothing</div> 
     114<div><?php echo _('Nothing'); ?></div> 
    115115<?php endif; ?> 
    116116                                </div> 
     
    118118                        <div id="content"> 
    119119                                <div class="queuebox first"> 
    120                                         Queued: <?php echo $c->queueLength; ?> items totalling <?php echo $c->queueSize; ?>MB 
     120                                        <?php printf(_('Queued: %s items totalling %sMB'), $c->queueLength, $c->queueSize); ?> 
    121121                                </div> 
    122122                                <?php if ($c->queueLength > 0): ?> 
     
    128128                <div class="queuetitle"><?php echo htmlspecialchars($queue['nzbName']); ?></div> 
    129129                <ul class="queuecontrols"> 
    130                         <li class="handle">Drag me</li><li class="control"><a href="index.php?info=<?php echo $i; ?>&amp;KeepThis=true&amp;TB_iframe=true&amp;height=200&amp;width=500" class="thickbox"><img src="images/information.png" alt="Info" /></a></li><li class="control"><a title="Cancel" href="<?php echo $self; ?>?action=1&amp;id=<?php echo $queue['id']; ?>"><img src="images/delete.png" alt="Cancel" /></a></li><li class="control"><a title="Up" href="<?php echo $self; ?>?action=2&amp;id=<?php echo $queue['id']; ?>"><img src="images/up.png" alt="Up" /></a></li><li class="control"><a title="Down" href="<?php echo $self; ?>?action=3&amp;id=<?php echo $queue['id']; ?>"><img src="images/down.png" alt="Down" /></a></li><li class="control"><a title="Top" href="<?php echo $self; ?>?action=4&amp;id=<?php echo $queue['id']; ?>"><img src="images/top.png" alt="Top" /></a></li><li class="control"><a title="Bottom" href="<?php echo $self; ?>?action=5&amp;id=<?php echo $queue['id']; ?>"><img src="images/bottom.png" alt="Bottom" /></a></li><li class="control"><a title="Force" href="<?php echo $self; ?>?action=6&amp;id=<?php echo $queue['id']; ?>"><img src="images/force.png" alt="Force" /></a></li> 
     130                        <li class="handle"><?php echo _('Drag me'); ?></li><li class="control"><a href="index.php?info=<?php echo $i; ?>&amp;KeepThis=true&amp;TB_iframe=true&amp;height=200&amp;width=500" class="thickbox"><img src="images/information.png" alt="Info" /></a></li><li class="control"><a title="Cancel" href="<?php echo $self; ?>?action=1&amp;id=<?php echo $queue['id']; ?>"><img src="images/delete.png" alt="Cancel" /></a></li><li class="control"><a title="Up" href="<?php echo $self; ?>?action=2&amp;id=<?php echo $queue['id']; ?>"><img src="images/up.png" alt="Up" /></a></li><li class="control"><a title="Down" href="<?php echo $self; ?>?action=3&amp;id=<?php echo $queue['id']; ?>"><img src="images/down.png" alt="Down" /></a></li><li class="control"><a title="Top" href="<?php echo $self; ?>?action=4&amp;id=<?php echo $queue['id']; ?>"><img src="images/top.png" alt="Top" /></a></li><li class="control"><a title="Bottom" href="<?php echo $self; ?>?action=5&amp;id=<?php echo $queue['id']; ?>"><img src="images/bottom.png" alt="Bottom" /></a></li><li class="control"><a title="Force" href="<?php echo $self; ?>?action=6&amp;id=<?php echo $queue['id']; ?>"><img src="images/force.png" alt="Force" /></a></li> 
    131131                </ul> 
    132                 <div class="queuestats"><?php echo $queue['total_mb']; ?>MB<?php echo ($c->transferRate > 0) ? ' ETA: ' . $c->formatTimeStamp($queue['eta']) : ''; ?></div> 
     132                <div class="queuestats"><?php printf(_('%sMB'), $queue['total_mb']); if ($c->transferRate > 0): printf(_(' ETA: %s'), $c->formatTimeStamp($queue['eta'])); endif; ?></div> 
    133133        </li> 
    134134<?php endforeach; ?> 
     
    137137                                <div id="controls"> 
    138138                                        <span id="refresher"> 
    139                                                 <input type="checkbox" name="refresh" id="refresh" onclick="if (this.checked) { createCookie('HHRefresh', 1, 30);startRefresher(); } else { createCookie('HHRefresh', 0, 30);stopRefresher(); }" /> <label for="refresh" class="refresher">Refresh every 15 seconds</label> 
     139                                                <input type="checkbox" name="refresh" id="refresh" onclick="if (this.checked) { createCookie('HHRefresh', 1, 30);startRefresher(); } else { createCookie('HHRefresh', 0, 30);stopRefresher(); }" /> <label for="refresh" class="refresher"><?php echo _('Refresh every 15 seconds'); ?></label> 
    140140                                        </span> 
    141141                                        <?php if ($c->queueLength > 0): ?> 
    142                                         <input type="submit" name="reorder" value="Reorder Items" /> by <select name="sorttype" id="sorttype" onchange="showstatus(this);"><option value="1">Provided Order</option><option value="2">Name</option><option value="3">Size</option></select> <select name="sortdirection" id="sortdirection"><option value="1">Ascending</option><option value="2">Descending</option></select> 
     142                                        <input type="submit" name="reorder" value="<?php echo _('Reorder Items'); ?>" /> <?php echo _('by'); ?> <select name="sorttype" id="sorttype" onchange="showstatus(this);"><option value="1"><?php echo _('Provided Order'); ?></option><option value="2"><?php echo _('Name'); ?></option><option value="3"><?php echo _('Size'); ?></option></select> <select name="sortdirection" id="sortdirection"><option value="1"><?php echo _('Ascending'); ?></option><option value="2"><?php echo _('Descending'); ?></option></select> 
    143143                                        <?php endif; ?> 
    144144                                </div> 
     
    150150<div id="tabcontainer"> 
    151151        <ul> 
    152                 <li><a accesskey="1" href="#fragment-1"><span>Log entries</span></a></li> 
    153                 <?php if (isset($config['showfinished']) && $config['showfinished']): ?><li><a accesskey="2" href="#fragment-2"><span>Finished Items</span></a></li><?php endif; ?> 
    154                 <li><a accesskey="3" href="#fragment-3"><span>Bookmarklet</span></a></li> 
     152                <li><a accesskey="1" href="#fragment-1"><span><?php echo _('Log Entries'); ?></span></a></li> 
     153                <?php if (isset($config['showfinished']) && $config['showfinished']): ?><li><a accesskey="2" href="#fragment-2"><span><?php echo _('Finished Items'); ?></span></a></li><?php endif; ?> 
     154                <li><a accesskey="3" href="#fragment-3"><span><?php echo _('Bookmarklet'); ?></span></a></li> 
    155155        </ul> 
    156156<div id="fragment-1"> 
     
    162162        <form action="<?php echo $self; ?>" method="post"> 
    163163                <div id="finishedcontrols"> 
    164                         <span id="finishedcount">Finished items: <?php echo $finishedcount; ?></span> 
     164                        <span id="finishedcount"><?php printf(_('Finished items: %s'), $finishedcount); ?></span> 
    165165                        <?php if ($finishedcount > 0): ?> 
    166                         <input type="submit" name="clearnzbs" value="Clear Finished NZBs" /> 
     166                        <input type="submit" name="clearnzbs" value="<?php echo _('Clear Finished NZBs'); ?>" /> 
    167167                        <?php endif; ?> 
    168168                </div> 
     
    176176                        </div> 
    177177                        <ul class="queuecontrols"> 
    178                                 <li class="control"><a href="<?php echo $self; ?>?removefinished=<?php echo $i; ?>">Remove</a></li> 
     178                                <li class="control"><a href="<?php echo $self; ?>?removefinished=<?php echo $i; ?>"><?php echo _('Remove'); ?></a></li> 
    179179                        </ul> 
    180                         <div class="queuestats">Finished on: <?php echo date('M dS - H:i:s', (int)$item->finishedTime); ?> Processing Time: <?php echo $item->elapsedTime; ?><?php if (trim($item->parMessage) != ""): ?> Par message: <?php echo $item->parMessage; endif; ?></div> 
     180                        <div class="queuestats"><?php printf(_('Finished on: %s Processing Time: %s'), date('M dS - H:i:s', (int)$item->finishedTime), $time->elapsedTime); if (trim($item->parMessage) != ''): printf(_(' Par message: %s'), $item->parMessage); endif; ?></div> 
    181181                </li> 
    182182                <?php endforeach; ?> 
     
    187187                <?php endif; ?> 
    188188<div id="fragment-3"> 
    189 <h2>HellaWorld Bookmarklet</h2> 
    190 <p class="bkmark">Right click on this link and bookmark it, or drag it to your bookmarks/favorites to create a Newzbin shortcut. Clicking on this shortcut when on a Newzbin article will add the NZB to HellaNZB's queue.</p> 
    191 <p class="bkmark"><a href="javascript:c=location.href;if(document.title.indexOf('Newzbin'+String.fromCharCode(32)+'-'+String.fromCharCode(32)+'Report')!=-1){location.href='<?php echo $protocol . '://' . htmlentities($_SERVER['HTTP_HOST']) . $self ?>?bookmarklet='+encodeURIComponent(c);}else{void(0);}">Send to HellaWorld</a></p> 
     189<h2><?php echo _('HellaWorld Bookmarklet'); ?></h2> 
     190<p class="bkmark"><?php echo _("Right click on this link and bookmark it, or drag it to your bookmarks/favorites to create a Newzbin shortcut. Clicking on this shortcut when on a Newzbin article will add the NZB to HellaNZB's queue."); ?></p> 
     191<p class="bkmark"><a href="javascript:c=location.href;if(document.title.indexOf('Newzbin'+String.fromCharCode(32)+'-'+String.fromCharCode(32)+'Report')!=-1){location.href='<?php echo $protocol . '://' . htmlentities($_SERVER['HTTP_HOST']) . $self ?>?bookmarklet='+encodeURIComponent(c);}else{void(0);}"><?php echo _('Send to HellaWorld'); ?></a></p> 
    192192</div> 
    193193</div> 
  • trunk/templates/rarpass.php

    r80 r133  
    4242        <head> 
    4343                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    44                 <title>Set Rar Password</title> 
     44                <title><?php echo _('Set Rar Password'); ?></title> 
    4545                <link rel="stylesheet" type="text/css" href="style/rarpass.css" /> 
    4646        </head> 
     
    4949<?php if (isset($submitted)): ?> 
    5050                <div id="response"> 
    51                         Rar password updated 
     51                        <?php echo _('Rar password updated'); ?> 
    5252                </div> 
    5353<?php else: ?> 
     
    5555                        <p><?php echo htmlspecialchars($c->queue[$index]['nzbName']); ?></p> 
    5656                        <form action="index.php?id=<?php echo $c->queue[$index]['id']; ?>" method="post"> 
    57                                 <label for="password">Password: <input type="password" name="password" id="password" /></label> 
    58                                 <input type="submit" value="Set Password" /> 
     57                                <label for="password"><?php echo _('Password:'); ?> <input type="password" name="password" id="password" /></label> 
     58                                <input type="submit" value="<?php echo _('Set Password'); ?>" /> 
    5959                        </form> 
    6060                </div>