summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gallery.php38
-rw-r--r--lib/mail.php2
-rw-r--r--lib/openid.php18
-rw-r--r--lib/settingsaction.php43
-rw-r--r--lib/stream.php12
-rw-r--r--lib/util.php77
6 files changed, 96 insertions, 94 deletions
diff --git a/lib/gallery.php b/lib/gallery.php
index 22488b3fd..4f3c18ff9 100644
--- a/lib/gallery.php
+++ b/lib/gallery.php
@@ -50,20 +50,20 @@ class GalleryAction extends Action {
}
function no_such_user() {
- $this->client_error(_t('No such user.'));
+ $this->client_error(_('No such user.'));
}
-
+
function show_top($profile) {
common_element('div', 'instructions',
$this->get_instructions($profile));
}
-
+
function show_gallery($profile, $page) {
$subs = new Subscription();
-
+
$this->define_subs($subs, $profile);
-
+
$subs->orderBy('created DESC');
# We ask for an extra one to know if we need to do another page
@@ -73,16 +73,16 @@ class GalleryAction extends Action {
$subs_count = $subs->find();
if ($subs_count == 0) {
- common_element('p', _t('Nobody to show!'));
+ common_element('p', _('Nobody to show!'));
return;
}
-
+
common_element_start('ul', $this->div_class());
for ($idx = 0; $idx < min($subs_count, AVATARS_PER_PAGE); $idx++) {
-
+
$result = $subs->fetch();
-
+
if (!$result) {
common_debug('Ran out of subscribers too early.', __FILE__);
break;
@@ -91,16 +91,16 @@ class GalleryAction extends Action {
$other = Profile::staticGet($this->get_other($subs));
common_element_start('li');
-
+
common_element_start('a', array('title' => ($other->fullname) ?
$other->fullname :
$other->nickname,
'href' => $other->profileurl,
'class' => 'subscription'));
$avatar = $other->getAvatar(AVATAR_STREAM_SIZE);
- common_element('img',
- array('src' =>
- (($avatar) ? common_avatar_display_url($avatar) :
+ common_element('img',
+ array('src' =>
+ (($avatar) ? common_avatar_display_url($avatar) :
common_default_avatar(AVATAR_STREAM_SIZE)),
'width' => AVATAR_STREAM_SIZE,
'height' => AVATAR_STREAM_SIZE,
@@ -111,19 +111,19 @@ class GalleryAction extends Action {
common_element_end('a');
# XXX: subscribe form here
-
+
common_element_end('li');
}
common_element_end('ul');
- common_pagination($page > 1,
+ common_pagination($page > 1,
$subs_count > AVATARS_PER_PAGE,
- $page,
- $this->trimmed('action'),
+ $page,
+ $this->trimmed('action'),
array('nickname' => $profile->nickname));
}
-
+
function gallery_type() {
return NULL;
}
@@ -139,7 +139,7 @@ class GalleryAction extends Action {
function get_other(&$subs) {
return NULL;
}
-
+
function div_class() {
return '';
}
diff --git a/lib/mail.php b/lib/mail.php
index ef33b2127..2f30d736c 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -79,7 +79,7 @@ function mail_confirm_address($code, $nickname, $address) {
$recipients = $address;
$headers['From'] = mail_notify_from();
$headers['To'] = $nickname . ' <' . $address . '>';
- $headers['Subject'] = _t('Email address confirmation');
+ $headers['Subject'] = _('Email address confirmation');
$body = "Hey, $nickname.";
$body .= "\n\n";
diff --git a/lib/openid.php b/lib/openid.php
index 5ad744fa1..6e501c2b1 100644
--- a/lib/openid.php
+++ b/lib/openid.php
@@ -118,7 +118,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) {
$consumer = oid_consumer();
if (!$consumer) {
- common_server_error(_t('Cannot instantiate OpenID consumer object.'));
+ common_server_error(_('Cannot instantiate OpenID consumer object.'));
return false;
}
@@ -128,9 +128,9 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) {
// Handle failure status return values.
if (!$auth_request) {
- return _t('Not a valid OpenID.');
+ return _('Not a valid OpenID.');
} else if (Auth_OpenID::isFailure($auth_request)) {
- return _t('OpenID failure: ') . $auth_request->message;
+ return sprintf(_('OpenID failure: %s'), $auth_request->message);
}
$sreg_request = Auth_OpenID_SRegRequest::build(// Required
@@ -157,7 +157,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) {
$immediate);
if (!$redirect_url) {
} else if (Auth_OpenID::isFailure($redirect_url)) {
- return _t('Could not redirect to server: ') . $redirect_url->message;
+ return sprintf(_('Could not redirect to server: %s'), $redirect_url->message);
} else {
common_redirect($redirect_url);
}
@@ -175,9 +175,9 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) {
// Display an error if the form markup couldn't be generated;
// otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) {
- $this->show_form(_t('Could not create OpenID form: ') . $form_html->message);
+ $this->show_form(sprintf(_('Could not create OpenID form: %s'), $form_html->message));
} else {
- common_show_header(_t('OpenID Auto-Submit'), NULL, NULL, '_oid_print_instructions');
+ common_show_header(_('OpenID Auto-Submit'), NULL, NULL, '_oid_print_instructions');
common_raw($form_html);
common_element('script', NULL,
'$(document).ready(function() { ' .
@@ -192,7 +192,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) {
function _oid_print_instructions() {
common_element('div', 'instructions',
- _t('This form should automatically submit itself. '.
+ _('This form should automatically submit itself. '.
'If not, click the submit button to go to your '.
'OpenID provider.'));
}
@@ -223,7 +223,7 @@ function oid_update_user(&$user, &$sreg) {
# XXX save timezone if it's passed
if (!$profile->update($orig_profile)) {
- common_server_error(_t('Error saving the profile.'));
+ common_server_error(_('Error saving the profile.'));
return false;
}
@@ -234,7 +234,7 @@ function oid_update_user(&$user, &$sreg) {
}
if (!$user->update($orig_user)) {
- common_server_error(_t('Error saving the user.'));
+ common_server_error(_('Error saving the user.'));
return false;
}
diff --git a/lib/settingsaction.php b/lib/settingsaction.php
index 1fbf88ecb..22be36720 100644
--- a/lib/settingsaction.php
+++ b/lib/settingsaction.php
@@ -24,7 +24,7 @@ class SettingsAction extends Action {
function handle($args) {
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_t('Not logged in.'));
+ common_user_error(_('Not logged in.'));
return;
} else if (!common_is_real_login()) {
# Cookie theft means that automatic logins can't
@@ -80,21 +80,30 @@ class SettingsAction extends Action {
function settings_menu() {
# action => array('prompt', 'title')
static $menu =
- array('profilesettings' =>
- array('Profile',
- 'Change your profile settings'),
- 'avatar' =>
- array('Avatar',
- 'Upload a new profile image'),
- 'password' =>
- array('Password',
- 'Change your password'),
- 'openidsettings' =>
- array('OpenID',
- 'Add or remove OpenIDs'),
- 'imsettings' =>
- array('IM',
- 'Updates by instant messenger (IM)'));
- $this->nav_menu($menu);
+ array('profilesettings' =>
+ array('Profile',
+ 'Change your profile settings'),
+ 'avatar' =>
+ array('Avatar',
+ 'Upload a new profile image'),
+ 'password' =>
+ array('Password',
+ 'Change your password'),
+ 'openidsettings' =>
+ array('OpenID',
+ 'Add or remove OpenIDs'),
+ 'imsettings' =>
+ array('IM',
+ 'Updates by instant messenger (IM)'));
+
+ $action = $this->trimmed('action');
+ common_element_start('ul', array('id' => 'nav_views'));
+ foreach ($menu as $menuaction => $menudesc) {
+ common_menu_item(common_local_url($menuaction),
+ _t($menudesc[0]),
+ _t($menudesc[1]),
+ $action == $menuaction);
+ }
+ common_element_end('ul');
}
}
diff --git a/lib/stream.php b/lib/stream.php
index 65d67d92d..a908b48e8 100644
--- a/lib/stream.php
+++ b/lib/stream.php
@@ -41,17 +41,17 @@ class StreamAction extends Action {
common_menu_item(common_local_url('all', array('nickname' =>
$nickname)),
- _t('Personal'),
- (($user && $user->fullname) ? $user->fullname : $nickname) . _t(' and friends'),
+ _('Personal'),
+ sprintf(_('%s and friends'), (($user && $user->fullname) ? $user->fullname : $nickname)),
$action == 'all');
common_menu_item(common_local_url('replies', array('nickname' =>
$nickname)),
- _t('Replies'),
- _t('Replies to ') . (($user && $user->fullname) ? $user->fullname : $nickname),
+ _('Replies'),
+ sprintf(_('Replies to %s'), (($user && $user->fullname) ? $user->fullname : $nickname)),
$action == 'replies');
common_menu_item(common_local_url('showstream', array('nickname' =>
$nickname)),
- _t('Profile'),
+ _('Profile'),
($user && $user->fullname) ? $user->fullname : $nickname,
$action == 'showstream');
common_element_end('ul');
@@ -98,7 +98,7 @@ class StreamAction extends Action {
common_text(' (');
common_element('a', array('class' => 'inreplyto',
'href' => $replyurl),
- _t('in reply to...'));
+ _t(' in reply to...'));
common_text(')');
}
common_element_start('a',
diff --git a/lib/util.php b/lib/util.php
index 432528074..c20075b30 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -144,7 +144,7 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall=
common_accept_to_prefs(PAGE_TYPE_PREFS));
if (!$type) {
- common_user_error(_t('This page is not available in a media type you accept'), 406);
+ common_user_error(_('This page is not available in a media type you accept'), 406);
exit(0);
}
@@ -230,15 +230,15 @@ function common_show_footer() {
common_element_start('div', array('id' => 'footer'));
common_element_start('div', 'laconica');
if (common_config('site', 'broughtby')) {
- $instr = _t('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
+ $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
} else {
- $instr = _t('**%%site.name%%** is a microblogging service. ');
+ $instr = _('**%%site.name%%** is a microblogging service. ');
}
- $instr .= _t('It runs the [Laconica](http://laconi.ca/) ' .
- 'microblogging software, version ' . LACONICA_VERSION . ', ' .
+ $instr .= sprintf(_('It runs the [Laconica](http://laconi.ca/) ' .
+ 'microblogging software, version %s, ' .
'available under the ' .
'[GNU Affero General Public License]' .
- '(http://www.fsf.org/licensing/licenses/agpl-3.0.html).');
+ '(http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), LACONICA_VERSION);
$output = common_markup_to_html($instr);
common_raw($output);
common_element_end('div');
@@ -246,12 +246,12 @@ function common_show_footer() {
'src' => $config['license']['image'],
'alt' => $config['license']['title']));
common_element_start('p');
- common_text(_t('Unless otherwise specified, contents of this site are copyright by the contributors and available under the '));
+ common_text(_('Unless otherwise specified, contents of this site are copyright by the contributors and available under the '));
common_element('a', array('class' => 'license',
'rel' => 'license',
href => $config['license']['url']),
$config['license']['title']);
- common_text(_t('. Contributors should be attributed by full name or nickname.'));
+ common_text(_('. Contributors should be attributed by full name or nickname.'));
common_element_end('p');
common_element_end('div');
common_element_end('div');
@@ -275,21 +275,20 @@ function common_nav_menu() {
common_element_start('ul', array('id' => 'nav'));
if ($user) {
common_menu_item(common_local_url('all', array('nickname' => $user->nickname)),
- _t('Home'));
+ _('Home'));
}
common_menu_item(common_local_url('public'), _t('Public'));
- common_menu_item(common_local_url('peoplesearch'), _t('Search'));
common_menu_item(common_local_url('doc', array('title' => 'help')),
- _t('Help'));
+ _('Help'));
if ($user) {
common_menu_item(common_local_url('profilesettings'),
- _t('Settings'));
+ _('Settings'));
common_menu_item(common_local_url('logout'),
- _t('Logout'));
+ _('Logout'));
} else {
- common_menu_item(common_local_url('login'), _t('Login'));
- common_menu_item(common_local_url('register'), _t('Register'));
- common_menu_item(common_local_url('openidlogin'), _t('OpenID'));
+ common_menu_item(common_local_url('login'), _('Login'));
+ common_menu_item(common_local_url('register'), _('Register'));
+ common_menu_item(common_local_url('openidlogin'), _('OpenID'));
}
common_element_end('ul');
}
@@ -297,15 +296,15 @@ function common_nav_menu() {
function common_foot_menu() {
common_element_start('ul', array('id' => 'nav_sub'));
common_menu_item(common_local_url('doc', array('title' => 'about')),
- _t('About'));
+ _('About'));
common_menu_item(common_local_url('doc', array('title' => 'faq')),
- _t('FAQ'));
+ _('FAQ'));
common_menu_item(common_local_url('doc', array('title' => 'privacy')),
- _t('Privacy'));
+ _('Privacy'));
common_menu_item(common_local_url('doc', array('title' => 'source')),
- _t('Source'));
+ _('Source'));
common_menu_item(common_local_url('doc', array('title' => 'contact')),
- _t('Contact'));
+ _('Contact'));
common_element_end('ul');
}
@@ -815,25 +814,25 @@ function common_date_string($dt) {
if ($now < $t) { # that shouldn't happen!
return common_exact_date($dt);
} else if ($diff < 60) {
- return _t('a few seconds ago');
+ return _('a few seconds ago');
} else if ($diff < 92) {
- return _t('about a minute ago');
+ return _('about a minute ago');
} else if ($diff < 3300) {
- return _t('about ') . round($diff/60) . _t(' minutes ago');
+ return sprintf(_('about %d minutes ago'), round($diff/60));
} else if ($diff < 5400) {
- return _t('about an hour ago');
+ return _('about an hour ago');
} else if ($diff < 22 * 3600) {
- return _t('about ') . round($diff/3600) . _t(' hours ago');
+ return sprintf(_('about %d hours ago'), round($diff/3600));
} else if ($diff < 37 * 3600) {
- return _t('about a day ago');
+ return _('about a day ago');
} else if ($diff < 24 * 24 * 3600) {
- return _t('about ') . round($diff/(24*3600)) . _t(' days ago');
+ return sprintf(_('about %d days ago', round($diff/(24*3600))));
} else if ($diff < 46 * 24 * 3600) {
- return _t('about a month ago');
+ return _('about a month ago');
} else if ($diff < 330 * 24 * 3600) {
- return _t('about ') . round($diff/(30*24*3600)) . _t(' months ago');
+ return sprintf(_('about %d months ago'), round($diff/(30*24*3600)));
} else if ($diff < 480 * 24 * 3600) {
- return _t('about a year ago');
+ return _('about a year ago');
} else {
return common_exact_date($dt);
}
@@ -923,7 +922,7 @@ function common_enqueue_notice($notice) {
common_log(LOG_DEBUG, 'complete queueing notice ID = ' . $notice->id);
return $result;
}
-
+
function common_real_broadcast($notice, $remote=false) {
$success = true;
if (!$remote) {
@@ -969,7 +968,7 @@ function common_notice_form($action=NULL, $content=NULL) {
common_element_start('p');
common_element('label', array('for' => 'status_textarea',
'id' => 'status_label'),
- _t('What\'s up, ').$user->nickname.'?');
+ sprintf(_('What\'s up, %s?'), $user->nickname));
common_element('span', array('id' => 'counter', 'class' => 'counter'), '140');
common_element('textarea', array('id' => 'status_textarea',
'cols' => 60,
@@ -982,7 +981,7 @@ function common_notice_form($action=NULL, $content=NULL) {
common_element('input', array('id' => 'status_submit',
'name' => 'status_submit',
'type' => 'submit',
- 'value' => _t('Send')));
+ 'value' => _('Send')));
common_element_end('p');
common_element_end('form');
}
@@ -1046,12 +1045,6 @@ function common_timestamp() {
return date('YmdHis');
}
-// XXX: set up gettext
-
-function _t($str) {
- return $str;
-}
-
function common_ensure_syslog() {
static $initialized = false;
if (!$initialized) {
@@ -1133,7 +1126,7 @@ function common_pagination($have_before, $have_after, $page, $action, $args=NULL
common_element_start('li', 'before');
common_element('a', array('href' => common_local_url($action, $newargs)),
- _t('« After'));
+ _('« After'));
common_element_end('li');
}
@@ -1142,7 +1135,7 @@ function common_pagination($have_before, $have_after, $page, $action, $args=NULL
$newargs = ($args) ? array_merge($args,$pargs) : $pargs;
common_element_start('li', 'after');
common_element('a', array('href' => common_local_url($action, $newargs)),
- _t('Before »'));
+ _('Before »'));
common_element_end('li');
}