start at i18n

This commit is contained in:
Mike Macgirvin 2010-07-26 22:48:08 -07:00
parent d6b3d091a6
commit e15265be3c
3 changed files with 24 additions and 9 deletions

View File

@ -39,6 +39,7 @@ class App {
public $argc; public $argc;
public $module; public $module;
public $pager; public $pager;
public $strings;
private $scheme; private $scheme;
private $hostname; private $hostname;
@ -175,6 +176,19 @@ function replace_macros($s,$r) {
}} }}
function load_translation_table($lang) {
global $a;
}
function t($s) {
global $a;
if($a->strings[$s])
return $a->strings[$s];
return $s;
}
if(! function_exists('fetch_url')) { if(! function_exists('fetch_url')) {
function fetch_url($url,$binary = false) { function fetch_url($url,$binary = false) {
@ -430,9 +444,9 @@ function paginate(&$a) {
if($a->pager['total'] > $a->pager['itemspage']) { if($a->pager['total'] > $a->pager['itemspage']) {
$o .= '<div class="pager">'; $o .= '<div class="pager">';
if($a->pager['page'] != 1) if($a->pager['page'] != 1)
$o .= '<span class="pager_prev">'."<a href=\"$url".'&page='.($a->pager['page'] - 1).'">prev</a></span> '; $o .= '<span class="pager_prev">'."<a href=\"$url".'&page='.($a->pager['page'] - 1).'">' . t('prev') . '</a></span> ';
$o .= "<span class=\"pager_first\"><a href=\"$url"."&page=1\">first</a></span> "; $o .= "<span class=\"pager_first\"><a href=\"$url"."&page=1\">" . t('first') . "</a></span> ";
$numpages = $a->pager['total'] / $a->pager['itemspage']; $numpages = $a->pager['total'] / $a->pager['itemspage'];
@ -461,10 +475,10 @@ function paginate(&$a) {
} }
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages); $lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
$o .= "<span class=\"pager_last\"><a href=\"$url"."&page=$lastpage\">last</a></span> "; $o .= "<span class=\"pager_last\"><a href=\"$url"."&page=$lastpage\">" . t('last') . "</a></span> ";
if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0) if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0)
$o .= '<span class="pager_next">'."<a href=\"$url"."&page=".($a->pager['page'] + 1).'">next</a></span>'; $o .= '<span class="pager_next">'."<a href=\"$url"."&page=".($a->pager['page'] + 1).'">' . t('next') . '</a></span>';
$o .= '</div>'."\r\n"; $o .= '</div>'."\r\n";
} }
return $o; return $o;
@ -481,3 +495,5 @@ function expand_acl($s) {
} }
return array(); return array();
} }

View File

@ -10,7 +10,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) {
unset($_SESSION['is_visitor']); unset($_SESSION['is_visitor']);
unset($_SESSION['administrator']); unset($_SESSION['administrator']);
unset($_SESSION['cid']); unset($_SESSION['cid']);
$_SESSION['sysmsg'] = "Logged out." . EOL; $_SESSION['sysmsg'] = t("Logged out.") . EOL;
goaway($a->get_baseurl()); goaway($a->get_baseurl());
} }
if(x($_SESSION,'uid')) { if(x($_SESSION,'uid')) {
@ -50,7 +50,7 @@ else {
dbesc(trim($_POST['login-name'])), dbesc(trim($_POST['login-name'])),
dbesc($encrypted)); dbesc($encrypted));
if(($r === false) || (! count($r))) { if(($r === false) || (! count($r))) {
$_SESSION['sysmsg'] = 'Login failed.' . EOL ; $_SESSION['sysmsg'] = t('Login failed.') . EOL ;
goaway($a->get_baseurl()); goaway($a->get_baseurl());
} }
$_SESSION['uid'] = $r[0]['uid']; $_SESSION['uid'] = $r[0]['uid'];
@ -58,7 +58,7 @@ else {
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname'];
$_SESSION['sysmsg'] = "Welcome back " . $r[0]['username'] . EOL; $_SESSION['sysmsg'] = t("Welcome back ") . $r[0]['username'] . EOL;
$a->user = $r[0]; $a->user = $r[0];
if(strlen($a->user['timezone'])) if(strlen($a->user['timezone']))
date_default_timezone_set($a->user['timezone']); date_default_timezone_set($a->user['timezone']);

View File

@ -1,8 +1,7 @@
<?php <?php
if(x($_SESSION['uid'])) { if(x($_SESSION['uid'])) {
$a->page['nav'] .= "<a id=\"nav-logout-link\" class=\"nav-link\" href=\"logout\">Logout</a>\r\n"; $a->page['nav'] .= "<a id=\"nav-logout-link\" class=\"nav-link\" href=\"logout\">" . t('Logout') . "</a>\r\n";
} }
$a->page['nav'] .= "<span id=\"nav-link-wrapper\" >\r\n"; $a->page['nav'] .= "<span id=\"nav-link-wrapper\" >\r\n";