From 428a22cc7628d5bf0f6c98f9912b5879d6c756dc Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Wed, 24 Jan 2018 07:18:21 -0500 Subject: [PATCH] More sprintf eliminate more sprintf( with L10n --- include/conversation.php | 42 ++++++++++++++++++++-------------------- mod/photos.php | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 91a835837e..94f5918744 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -203,7 +203,7 @@ function localize_item(&$item) { $Bphoto = '[url=' . Profile::zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]'; } - $item['body'] = sprintf( L10n::t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; + $item['body'] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$Bphoto; } if (stristr($item['verb'], ACTIVITY_POKE)) { @@ -298,7 +298,7 @@ function localize_item(&$item) { $parsedobj = parse_xml_string($xmlhead.$item['object']); $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content); - $item['body'] = sprintf( L10n::t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag ); + $item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag ); } if (activity_match($item['verb'], ACTIVITY_FAVORITE)) { @@ -326,7 +326,7 @@ function localize_item(&$item) { $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]'; $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]'; $P = '[url=' . $target['plink'] . ']' . L10n::t('post/item') . '[/url]'; - $item['body'] = sprintf( L10n::t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n"; + $item['body'] = L10n::t('%1$s marked %2$s\'s %3$s as favorite', $A, $B, $P)."\n"; } } } @@ -780,7 +780,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { 'guid' => (($preview) ? 'Q0' : $item['guid']), 'network' => $item['item_network'], 'network_name' => ContactSelector::networkToName($item['item_network'], $profile_link), - 'linktitle' => sprintf( L10n::t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $profile_name_e, @@ -800,7 +800,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { 'folders' => $folders, 'text' => strip_tags($body_e), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), - 'ago' => (($item['app']) ? sprintf( L10n::t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])), 'location' => $location_e, 'indent' => '', 'owner_name' => $owner_name_e, @@ -1188,19 +1188,19 @@ function format_like($cnt, array $arr, $type, $id) { // list which show all likers switch ($type) { case 'like' : - $phrase = sprintf( L10n::t('%s likes this.'), $likers); + $phrase = L10n::t('%s likes this.', $likers); break; case 'dislike' : - $phrase = sprintf( L10n::t('%s doesn\'t like this.'), $likers); + $phrase = L10n::t('%s doesn\'t like this.', $likers); break; case 'attendyes' : - $phrase = sprintf( L10n::t('%s attends.'), $likers); + $phrase = L10n::t('%s attends.', $likers); break; case 'attendno' : - $phrase = sprintf( L10n::t('%s doesn\'t attend.'), $likers); + $phrase = L10n::t('%s doesn\'t attend.', $likers); break; case 'attendmaybe' : - $phrase = sprintf( L10n::t('%s attends maybe.'), $likers); + $phrase = L10n::t('%s attends maybe.', $likers); break; } } @@ -1217,7 +1217,7 @@ function format_like($cnt, array $arr, $type, $id) { } if ($total >= MAX_LIKERS) { $str = implode(', ', $arr); - $str .= sprintf( L10n::t(', and %d other people'), $total - MAX_LIKERS ); + $str .= L10n::t(', and %d other people', $total - MAX_LIKERS ); } $likers = $str; @@ -1226,24 +1226,24 @@ function format_like($cnt, array $arr, $type, $id) { switch ($type) { case 'like': - $phrase = sprintf( L10n::t('%2$d people like this'), $spanatts, $cnt); - $explikers = sprintf( L10n::t('%s like this.'), $likers); + $phrase = L10n::t('%2$d people like this', $spanatts, $cnt); + $explikers = L10n::t('%s like this.', $likers); break; case 'dislike': - $phrase = sprintf( L10n::t('%2$d people don\'t like this'), $spanatts, $cnt); - $explikers = sprintf( L10n::t('%s don\'t like this.'), $likers); + $phrase = L10n::t('%2$d people don\'t like this', $spanatts, $cnt); + $explikers = L10n::t('%s don\'t like this.', $likers); break; case 'attendyes': - $phrase = sprintf( L10n::t('%2$d people attend'), $spanatts, $cnt); - $explikers = sprintf( L10n::t('%s attend.'), $likers); + $phrase = L10n::t('%2$d people attend', $spanatts, $cnt); + $explikers = L10n::t('%s attend.', $likers); break; case 'attendno': - $phrase = sprintf( L10n::t('%2$d people don\'t attend'), $spanatts, $cnt); - $explikers = sprintf( L10n::t('%s don\'t attend.'), $likers); + $phrase = L10n::t('%2$d people don\'t attend', $spanatts, $cnt); + $explikers = L10n::t('%s don\'t attend.', $likers); break; case 'attendmaybe': - $phrase = sprintf( L10n::t('%2$d people attend maybe'), $spanatts, $cnt); - $explikers = sprintf( L10n::t('%s anttend maybe.'), $likers); + $phrase = L10n::t('%2$d people attend maybe', $spanatts, $cnt); + $explikers = L10n::t('%s anttend maybe.', $likers); break; } diff --git a/mod/photos.php b/mod/photos.php index ec0b6484e6..a789ac6413 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -695,7 +695,7 @@ function photos_post(App $a) $arr['tag'] = $tagged[4]; $arr['inform'] = $tagged[2]; $arr['origin'] = 1; - $arr['body'] = sprintf( L10n::t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . L10n::t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ; + $arr['body'] = L10n::t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . L10n::t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ; $arr['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . System::baseUrl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ; $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $tagged[0] . '' . $tagged[1] . '/' . $tagged[0] . '';