From a9a36fb3029c9a5d595aa28a9f0a79f441d1b121 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sat, 18 Jan 2020 20:53:01 +0100 Subject: [PATCH] Move L10n::tt() calls to DI::l10n()->tt() calls --- doc/translations.md | 12 ++++++------ include/api.php | 4 ++-- include/conversation.php | 10 +++++----- mod/dfrn_request.php | 4 ++-- mod/message.php | 2 +- mod/network.php | 2 +- src/Content/Widget.php | 4 ++-- src/Content/Widget/ContactBlock.php | 2 +- src/Content/Widget/TrendingTags.php | 2 +- src/Core/L10n.php | 4 ++-- src/Core/L10n/L10n.php | 4 ++-- src/Core/UserImport.php | 2 +- src/Model/User.php | 4 ++-- src/Module/Admin/Blocklist/Contact.php | 4 ++-- src/Module/Admin/Users.php | 6 +++--- src/Module/Contact.php | 2 +- src/Module/Invite.php | 2 +- src/Module/Profile/Contacts.php | 8 ++++---- src/Module/Security/TwoFactor/Verify.php | 2 +- src/Object/Post.php | 4 ++-- 20 files changed, 42 insertions(+), 42 deletions(-) diff --git a/doc/translations.md b/doc/translations.md index c1bd3ce88f..f12f070655 100644 --- a/doc/translations.md +++ b/doc/translations.md @@ -78,9 +78,9 @@ Then run `bin/console po2php view/lang//messages.po` to update the rel ### Plural -- `Friendica\Core\L10n::tt('Label', 'Labels', 1)` => `Label` -- `Friendica\Core\L10n::tt('Label', 'Labels', 3)` => `Labels` -- `Friendica\Core\L10n::tt('%d Label', '%d Labels', 1)` => `1 Label` -- `Friendica\Core\L10n::tt('%d Label', '%d Labels', 3)` => `3 Labels` -- `Friendica\Core\L10n::tt('%d Label', 'Labels %2%s %3%s', 1, 'test', 'test2')` => `Label test test2` -- `Friendica\Core\L10n::tt('%d Label', 'Labels %2%s %3%s', 3, 'test', 'test2')` => `Labels test test2` +- `Friendica\Core\DI::l10n()->tt('Label', 'Labels', 1)` => `Label` +- `Friendica\Core\DI::l10n()->tt('Label', 'Labels', 3)` => `Labels` +- `Friendica\Core\DI::l10n()->tt('%d Label', '%d Labels', 1)` => `1 Label` +- `Friendica\Core\DI::l10n()->tt('%d Label', '%d Labels', 3)` => `3 Labels` +- `Friendica\Core\DI::l10n()->tt('%d Label', 'Labels %2%s %3%s', 1, 'test', 'test2')` => `Label test test2` +- `Friendica\Core\DI::l10n()->tt('%d Label', 'Labels %2%s %3%s', 3, 'test', 'test2')` => `Labels test test2` diff --git a/include/api.php b/include/api.php index ab12d42bf3..583573b58c 100644 --- a/include/api.php +++ b/include/api.php @@ -1107,7 +1107,7 @@ function api_statuses_update($type) if ($posts_day > $throttle_day) { Logger::log('Daily posting limit reached for user '.api_user(), Logger::DEBUG); // die(api_error($type, DI::l10n()->t("Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); - throw new TooManyRequestsException(L10n::tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); + throw new TooManyRequestsException(DI::l10n()->tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day)); } } @@ -1121,7 +1121,7 @@ function api_statuses_update($type) if ($posts_week > $throttle_week) { Logger::log('Weekly posting limit reached for user '.api_user(), Logger::DEBUG); // die(api_error($type, DI::l10n()->t("Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week))); - throw new TooManyRequestsException(L10n::tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week)); + throw new TooManyRequestsException(DI::l10n()->tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week)); } } diff --git a/include/conversation.php b/include/conversation.php index d09c918d15..b541df3640 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1581,19 +1581,19 @@ function get_response_button_text($v, $count) $return = ''; switch ($v) { case 'like': - $return = L10n::tt('Like', 'Likes', $count); + $return = DI::l10n()->tt('Like', 'Likes', $count); break; case 'dislike': - $return = L10n::tt('Dislike', 'Dislikes', $count); + $return = DI::l10n()->tt('Dislike', 'Dislikes', $count); break; case 'attendyes': - $return = L10n::tt('Attending', 'Attending', $count); + $return = DI::l10n()->tt('Attending', 'Attending', $count); break; case 'attendno': - $return = L10n::tt('Not Attending', 'Not Attending', $count); + $return = DI::l10n()->tt('Not Attending', 'Not Attending', $count); break; case 'attendmaybe': - $return = L10n::tt('Undecided', 'Undecided', $count); + $return = DI::l10n()->tt('Undecided', 'Undecided', $count); break; } diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 001735ea82..888940af6c 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -128,7 +128,7 @@ function dfrn_request_post(App $a) } $invalid = Probe::validDfrn($parms); if ($invalid) { - notice(L10n::tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL); + notice(DI::l10n()->tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL); return; } } @@ -366,7 +366,7 @@ function dfrn_request_post(App $a) } $invalid = Probe::validDfrn($parms); if ($invalid) { - notice(L10n::tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL); + notice(DI::l10n()->tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid) . EOL); return; } diff --git a/mod/message.php b/mod/message.php index 06203b8394..bff62a554d 100644 --- a/mod/message.php +++ b/mod/message.php @@ -539,7 +539,7 @@ function render_messages(array $msg, $t) '$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')), '$ago' => Temporal::getRelativeDate($rr['mailcreated']), '$seen' => $rr['mailseen'], - '$count' => L10n::tt('%d message', '%d messages', $rr['count']), + '$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']), ]); } diff --git a/mod/network.php b/mod/network.php index 11650367b5..106705bd8a 100644 --- a/mod/network.php +++ b/mod/network.php @@ -491,7 +491,7 @@ function networkThreadedView(App $a, $update, $parent) $o .= $tabs; if ($gid && ($t = Contact::getOStatusCountByGroupId($gid)) && !DI::pConfig()->get(local_user(), 'system', 'nowarn_insecure')) { - notice(L10n::tt("Warning: This group contains %s member from a network that doesn't allow non public messages.", + notice(DI::l10n()->tt("Warning: This group contains %s member from a network that doesn't allow non public messages.", "Warning: This group contains %s members from a network that doesn't allow non public messages.", $t) . EOL); notice(DI::l10n()->t("Messages in this group won't be send to these receivers.").EOL); diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 7c412ae8fa..496bbfcb68 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -53,7 +53,7 @@ class Widget $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining')); if ($x || is_site_admin()) { DI::page()['aside'] .= ''; } } @@ -398,7 +398,7 @@ class Widget $tpl = Renderer::getMarkupTemplate('widget/remote_friends_common.tpl'); return Renderer::replaceMacros($tpl, [ - '$desc' => L10n::tt("%d contact in common", "%d contacts in common", $t), + '$desc' => DI::l10n()->tt("%d contact in common", "%d contacts in common", $t), '$base' => DI::baseUrl(), '$uid' => $profile_uid, '$cid' => (($cid) ? $cid : '0'), diff --git a/src/Content/Widget/ContactBlock.php b/src/Content/Widget/ContactBlock.php index 67f8d9ac51..fbb5683af1 100644 --- a/src/Content/Widget/ContactBlock.php +++ b/src/Content/Widget/ContactBlock.php @@ -87,7 +87,7 @@ class ContactBlock $contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'network'], ['id' => $contact_ids]); if (DBA::isResult($contacts_stmt)) { - $contacts_title = L10n::tt('%d Contact', '%d Contacts', $total); + $contacts_title = DI::l10n()->tt('%d Contact', '%d Contacts', $total); $micropro = []; while ($contact = DBA::fetch($contacts_stmt)) { diff --git a/src/Content/Widget/TrendingTags.php b/src/Content/Widget/TrendingTags.php index 561dec00ca..2e97c8157e 100644 --- a/src/Content/Widget/TrendingTags.php +++ b/src/Content/Widget/TrendingTags.php @@ -29,7 +29,7 @@ class TrendingTags $tpl = Renderer::getMarkupTemplate('widget/trending_tags.tpl'); $o = Renderer::replaceMacros($tpl, [ - '$title' => L10n::tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period), + '$title' => DI::l10n()->tt('Trending Tags (last %d hour)', 'Trending Tags (last %d hours)', $period), '$more' => DI::l10n()->t('More Trending Tags'), '$tags' => $tags, ]); diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 67c0e47744..7fc268ac42 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -67,8 +67,8 @@ class L10n * is performed using the count as parameter. * * Usages: - * - L10n::tt('Like', 'Likes', $count) - * - L10n::tt("%s user deleted", "%s users deleted", count($users)) + * - DI::l10n()->tt('Like', 'Likes', $count) + * - DI::l10n()->tt("%s user deleted", "%s users deleted", count($users)) * * @param string $singular * @param string $plural diff --git a/src/Core/L10n/L10n.php b/src/Core/L10n/L10n.php index 6868b4503c..d29e408481 100644 --- a/src/Core/L10n/L10n.php +++ b/src/Core/L10n/L10n.php @@ -254,8 +254,8 @@ class L10n * is performed using the count as parameter. * * Usages: - * - L10n::tt('Like', 'Likes', $count) - * - L10n::tt("%s user deleted", "%s users deleted", count($users)) + * - DI::l10n()->tt('Like', 'Likes', $count) + * - DI::l10n()->tt("%s user deleted", "%s users deleted", count($users)) * * @param string $singular * @param string $plural diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index d48d179fa6..c77674127a 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -216,7 +216,7 @@ class UserImport } } if ($errorcount > 0) { - notice(L10n::tt("%d contact not imported", "%d contacts not imported", $errorcount)); + notice(DI::l10n()->tt("%d contact not imported", "%d contacts not imported", $errorcount)); } foreach ($account['group'] as &$group) { diff --git a/src/Model/User.php b/src/Model/User.php index ffee6ede2a..8ae32d0cfd 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -667,11 +667,11 @@ class User } if (mb_strlen($username) < $username_min_length) { - throw new Exception(L10n::tt('Username should be at least %s character.', 'Username should be at least %s characters.', $username_min_length)); + throw new Exception(DI::l10n()->tt('Username should be at least %s character.', 'Username should be at least %s characters.', $username_min_length)); } if (mb_strlen($username) > $username_max_length) { - throw new Exception(L10n::tt('Username should be at most %s character.', 'Username should be at most %s characters.', $username_max_length)); + throw new Exception(DI::l10n()->tt('Username should be at most %s character.', 'Username should be at most %s characters.', $username_max_length)); } // So now we are just looking for a space in the full name. diff --git a/src/Module/Admin/Blocklist/Contact.php b/src/Module/Admin/Blocklist/Contact.php index bb7868f956..ed99a39f89 100644 --- a/src/Module/Admin/Blocklist/Contact.php +++ b/src/Module/Admin/Blocklist/Contact.php @@ -36,7 +36,7 @@ class Contact extends BaseAdminModule foreach ($contacts as $uid) { Model\Contact::unblock($uid); } - notice(L10n::tt('%s contact unblocked', '%s contacts unblocked', count($contacts))); + notice(DI::l10n()->tt('%s contact unblocked', '%s contacts unblocked', count($contacts))); } DI::baseUrl()->redirect('admin/blocklist/contact'); @@ -77,7 +77,7 @@ class Contact extends BaseAdminModule '$baseurl' => DI::baseUrl()->get(true), '$contacts' => $contacts, - '$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total), + '$total_contacts' => DI::l10n()->tt('%s total blocked contact', '%s total blocked contacts', $total), '$paginate' => $pager->renderFull($total), '$contacturl' => ['contact_url', DI::l10n()->t('Profile URL'), '', DI::l10n()->t('URL of the remote contact to block.')], '$contact_block_reason' => ['contact_block_reason', DI::l10n()->t('Block Reason')], diff --git a/src/Module/Admin/Users.php b/src/Module/Admin/Users.php index 543562d9da..2d38d5926c 100644 --- a/src/Module/Admin/Users.php +++ b/src/Module/Admin/Users.php @@ -92,13 +92,13 @@ class Users extends BaseAdminModule if (!empty($_POST['page_users_block'])) { // @TODO Move this to Model\User:block($users); DBA::update('user', ['blocked' => 1], ['uid' => $users]); - notice(L10n::tt('%s user blocked', '%s users blocked', count($users))); + notice(DI::l10n()->tt('%s user blocked', '%s users blocked', count($users))); } if (!empty($_POST['page_users_unblock'])) { // @TODO Move this to Model\User:unblock($users); DBA::update('user', ['blocked' => 0], ['uid' => $users]); - notice(L10n::tt('%s user unblocked', '%s users unblocked', count($users))); + notice(DI::l10n()->tt('%s user unblocked', '%s users unblocked', count($users))); } if (!empty($_POST['page_users_delete'])) { @@ -110,7 +110,7 @@ class Users extends BaseAdminModule } } - notice(L10n::tt('%s user deleted', '%s users deleted', count($users))); + notice(DI::l10n()->tt('%s user deleted', '%s users deleted', count($users))); } if (!empty($_POST['page_users_approve'])) { diff --git a/src/Module/Contact.php b/src/Module/Contact.php index 183a1bd16d..19e7363130 100644 --- a/src/Module/Contact.php +++ b/src/Module/Contact.php @@ -67,7 +67,7 @@ class Contact extends BaseModule } } if ($count_actions > 0) { - info(L10n::tt('%d contact edited.', '%d contacts edited.', $count_actions)); + info(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions)); } DI::baseUrl()->redirect('contact'); diff --git a/src/Module/Invite.php b/src/Module/Invite.php index cdc5ac6376..b467d14ec3 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -101,7 +101,7 @@ class Invite extends BaseModule } } - notice(L10n::tt('%d message sent.', '%d messages sent.', $total) . EOL); + notice(DI::l10n()->tt('%d message sent.', '%d messages sent.', $total) . EOL); } public static function content(array $parameters = []) diff --git a/src/Module/Profile/Contacts.php b/src/Module/Profile/Contacts.php index afde70e345..0e83f3070f 100644 --- a/src/Module/Profile/Contacts.php +++ b/src/Module/Profile/Contacts.php @@ -110,11 +110,11 @@ class Contacts extends BaseModule DBA::close($contacts_stmt); switch ($type) { - case 'followers': $title = L10n::tt('Follower (%s)', 'Followers (%s)', $total); break; - case 'following': $title = L10n::tt('Following (%s)', 'Following (%s)', $total); break; - case 'mutuals': $title = L10n::tt('Mutual friend (%s)', 'Mutual friends (%s)', $total); break; + case 'followers': $title = DI::l10n()->tt('Follower (%s)', 'Followers (%s)', $total); break; + case 'following': $title = DI::l10n()->tt('Following (%s)', 'Following (%s)', $total); break; + case 'mutuals': $title = DI::l10n()->tt('Mutual friend (%s)', 'Mutual friends (%s)', $total); break; - case 'all': default: $title = L10n::tt('Contact (%s)', 'Contacts (%s)', $total); break; + case 'all': default: $title = DI::l10n()->tt('Contact (%s)', 'Contacts (%s)', $total); break; } $tpl = Renderer::getMarkupTemplate('profile/contacts.tpl'); diff --git a/src/Module/Security/TwoFactor/Verify.php b/src/Module/Security/TwoFactor/Verify.php index a95b02d42e..968bab9dde 100644 --- a/src/Module/Security/TwoFactor/Verify.php +++ b/src/Module/Security/TwoFactor/Verify.php @@ -61,7 +61,7 @@ class Verify extends BaseModule '$title' => DI::l10n()->t('Two-factor authentication'), '$message' => DI::l10n()->t('

Open the two-factor authentication app on your device to get an authentication code and verify your identity.

'), - '$errors_label' => L10n::tt('Error', 'Errors', count(self::$errors)), + '$errors_label' => DI::l10n()->tt('Error', 'Errors', count(self::$errors)), '$errors' => self::$errors, '$recovery_message' => DI::l10n()->t('Don’t have your phone? Enter a two-factor recovery code', '2fa/recovery'), '$verify_code' => ['verify_code', DI::l10n()->t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'tel'], diff --git a/src/Object/Post.php b/src/Object/Post.php index efaa688199..c49061e0f1 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -480,7 +480,7 @@ class Post // Collapse if (($nb_children > 2) || ($thread_level > 1)) { $result['children'][0]['comment_firstcollapsed'] = true; - $result['children'][0]['num_comments'] = L10n::tt('%d comment', '%d comments', $total_children); + $result['children'][0]['num_comments'] = DI::l10n()->tt('%d comment', '%d comments', $total_children); $result['children'][0]['show_text'] = DI::l10n()->t('Show more'); $result['children'][0]['hide_text'] = DI::l10n()->t('Show fewer'); if ($thread_level > 1) { @@ -493,7 +493,7 @@ class Post if ($this->isToplevel()) { $result['total_comments_num'] = "$total_children"; - $result['total_comments_text'] = L10n::tt('comment', 'comments', $total_children); + $result['total_comments_text'] = DI::l10n()->tt('comment', 'comments', $total_children); } $result['private'] = $item['private'];