Review sprintf

remove more sprintf calls
This commit is contained in:
Adam Magness 2018-01-23 21:59:16 -05:00
parent f7e9b74dca
commit 208a149a7b
32 changed files with 205 additions and 188 deletions

View file

@ -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

View file

@ -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']

View file

@ -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) {