Review sprintf
remove more sprintf calls
This commit is contained in:
parent
f7e9b74dca
commit
208a149a7b
32 changed files with 205 additions and 188 deletions
|
@ -132,9 +132,9 @@ class L10n
|
|||
* string interpolation (sprintf) with additional optional arguments.
|
||||
*
|
||||
* Usages:
|
||||
* - t('This is an example')
|
||||
* - t('URL %s returned no result', $url)
|
||||
* - t('Current version: %s, new version: %s', $current_version, $new_version)
|
||||
* - L10n::t('This is an example')
|
||||
* - L10n::t('URL %s returned no result', $url)
|
||||
* - L10n::t('Current version: %s, new version: %s', $current_version, $new_version)
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
|
@ -165,8 +165,8 @@ class L10n
|
|||
* is performed using the count as parameter.
|
||||
*
|
||||
* Usages:
|
||||
* - tt('Like', 'Likes', $count)
|
||||
* - tt("%s user deleted", "%s users deleted", count($users))
|
||||
* - L10n::tt('Like', 'Likes', $count)
|
||||
* - L10n::tt("%s user deleted", "%s users deleted", count($users))
|
||||
*
|
||||
* @global type $lang
|
||||
* @param string $singular
|
||||
|
|
|
@ -251,7 +251,7 @@ class NotificationsManager extends BaseObject
|
|||
$default_item_link = System::baseUrl(true) . '/display/' . $it['pguid'];
|
||||
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||
$default_item_url = $it['author-link'];
|
||||
$default_item_text = sprintf(L10n::t("%s commented on %s's post"), $it['author-name'], $it['pname']);
|
||||
$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
|
||||
$default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
|
||||
$default_item_ago = relative_date($it['created']);
|
||||
break;
|
||||
|
@ -262,8 +262,8 @@ class NotificationsManager extends BaseObject
|
|||
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||
$default_item_url = $it['author-link'];
|
||||
$default_item_text = (($it['id'] == $it['parent'])
|
||||
? sprintf(L10n::t("%s created a new post"), $it['author-name'])
|
||||
: sprintf(L10n::t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
||||
? L10n::t("%s created a new post", $it['author-name'])
|
||||
: L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
|
||||
$default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
|
||||
$default_item_ago = relative_date($it['created']);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ class NotificationsManager extends BaseObject
|
|||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf(L10n::t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
||||
'text' => L10n::t("%s liked %s's post", $it['author-name'], $it['pname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
@ -289,7 +289,7 @@ class NotificationsManager extends BaseObject
|
|||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf(L10n::t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
||||
'text' => L10n::t("%s disliked %s's post", $it['author-name'], $it['pname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
@ -302,7 +302,7 @@ class NotificationsManager extends BaseObject
|
|||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf(L10n::t("%s is attending %s's event"), $it['author-name'], $it['pname']),
|
||||
'text' => L10n::t("%s is attending %s's event", $it['author-name'], $it['pname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
@ -315,7 +315,7 @@ class NotificationsManager extends BaseObject
|
|||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf(L10n::t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
|
||||
'text' => L10n::t("%s is not attending %s's event", $it['author-name'], $it['pname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
@ -328,7 +328,7 @@ class NotificationsManager extends BaseObject
|
|||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf(L10n::t("%s may attend %s's event"), $it['author-name'], $it['pname']),
|
||||
'text' => L10n::t("%s may attend %s's event", $it['author-name'], $it['pname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
@ -345,7 +345,7 @@ class NotificationsManager extends BaseObject
|
|||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
'url' => $it['author-link'],
|
||||
'text' => sprintf(L10n::t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
||||
'text' => L10n::t("%s is now friends with %s", $it['author-name'], $it['fname']),
|
||||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
|
|
|
@ -120,7 +120,7 @@ class UserImport
|
|||
}
|
||||
|
||||
if (DBM::is_result($r) > 0) {
|
||||
notice(sprintf(L10n::t("User '%s' already exists on this server!"), $account['user']['nickname']));
|
||||
notice(L10n::t("User '%s' already exists on this server!", $account['user']['nickname']));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ class UserImport
|
|||
}
|
||||
|
||||
if (DBM::is_result($r) > 0) {
|
||||
notice(sprintf(L10n::t("User '%s' already exists on this server!"), $account['user']['nickname']));
|
||||
notice(L10n::t("User '%s' already exists on this server!", $account['user']['nickname']));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ class UserImport
|
|||
}
|
||||
}
|
||||
if ($errorcount > 0) {
|
||||
notice(sprintf(L10n::tt("%d contact not imported", "%d contacts not imported", $errorcount), $errorcount));
|
||||
notice(L10n::tt("%d contact not imported", "%d contacts not imported", $errorcount));
|
||||
}
|
||||
|
||||
foreach ($account['group'] as &$group) {
|
||||
|
|
|
@ -188,7 +188,7 @@ class DBStructure
|
|||
* @return string Error message
|
||||
*/
|
||||
private static function printUpdateError($message) {
|
||||
echo sprintf(L10n::t("\nError %d occurred during database update:\n%s\n"),
|
||||
echo L10n::t("\nError %d occurred during database update:\n%s\n",
|
||||
dba::errorNo(), dba::errorMessage());
|
||||
|
||||
return L10n::t('Errors encountered performing database changes: ').$message.EOL;
|
||||
|
@ -206,7 +206,7 @@ class DBStructure
|
|||
public static function update($verbose, $action, array $tables = null, array $definition = null) {
|
||||
if ($action) {
|
||||
Config::set('system', 'maintenance', 1);
|
||||
Config::set('system', 'maintenance_reason', sprintf(L10n::t(': Database update'), DBM::date().' '.date('e')));
|
||||
Config::set('system', 'maintenance_reason', L10n::t(': Database update', DBM::date().' '.date('e')));
|
||||
}
|
||||
|
||||
$errors = '';
|
||||
|
@ -456,7 +456,7 @@ class DBStructure
|
|||
}
|
||||
|
||||
if ($action) {
|
||||
Config::set('system', 'maintenance_reason', sprintf(L10n::t('%s: updating %s table.'), DBM::date().' '.date('e'), $name));
|
||||
Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DBM::date().' '.date('e'), $name));
|
||||
|
||||
// Ensure index conversion to unique removes duplicates
|
||||
if ($is_unique && ($temp_name != $name)) {
|
||||
|
|
|
@ -532,7 +532,7 @@ class User
|
|||
return notification([
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf(L10n::t('Registration at %s'), $sitename),
|
||||
'subject'=> L10n::t('Registration at %s', $sitename),
|
||||
'body' => $body]);
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ class User
|
|||
return notification([
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf(L10n::t('Registration details for %s'), $sitename),
|
||||
'subject'=> L10n::t('Registration details for %s', $sitename),
|
||||
'preamble'=> $preamble,
|
||||
'body' => $body]);
|
||||
}
|
||||
|
|
|
@ -1394,8 +1394,8 @@ class DFRN
|
|||
|
||||
logger("updating birthday: ".$birthday." for contact ".$contact["id"]);
|
||||
|
||||
$bdtext = sprintf(L10n::t("%s\'s birthday"), $contact["name"]);
|
||||
$bdtext2 = sprintf(L10n::t("Happy Birthday %s"), " [url=".$contact["url"]."]".$contact["name"]."[/url]");
|
||||
$bdtext = L10n::t("%s\'s birthday", $contact["name"]);
|
||||
$bdtext2 = L10n::t("Happy Birthday %s", " [url=".$contact["url"]."]".$contact["name"]."[/url]");
|
||||
|
||||
$r = q(
|
||||
"INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`)
|
||||
|
|
|
@ -2406,7 +2406,7 @@ class Diaspora
|
|||
$A = "[url=".$self[0]["url"]."]".$self[0]["name"]."[/url]";
|
||||
$B = "[url=".$contact["url"]."]".$contact["name"]."[/url]";
|
||||
$BPhoto = "[url=".$contact["url"]."][img]".$contact["thumb"]."[/img][/url]";
|
||||
$arr["body"] = sprintf(L10n::t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto;
|
||||
$arr["body"] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$BPhoto;
|
||||
|
||||
$arr["object"] = self::constructNewFriendObject($contact);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue