Move L10n::tt() calls to DI::l10n()->tt() calls
authornupplaPhil <admin@philipp.info>
Sat, 18 Jan 2020 19:53:01 +0000 (20:53 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 19 Jan 2020 15:31:17 +0000 (16:31 +0100)
20 files changed:
doc/translations.md
include/api.php
include/conversation.php
mod/dfrn_request.php
mod/message.php
mod/network.php
src/Content/Widget.php
src/Content/Widget/ContactBlock.php
src/Content/Widget/TrendingTags.php
src/Core/L10n.php
src/Core/L10n/L10n.php
src/Core/UserImport.php
src/Model/User.php
src/Module/Admin/Blocklist/Contact.php
src/Module/Admin/Users.php
src/Module/Contact.php
src/Module/Invite.php
src/Module/Profile/Contacts.php
src/Module/Security/TwoFactor/Verify.php
src/Object/Post.php

index c1bd3ce..f12f070 100644 (file)
@@ -78,9 +78,9 @@ Then run `bin/console po2php view/lang/<language>/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`
index ab12d42..583573b 100644 (file)
@@ -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));
                        }
                }
 
index d09c918..b541df3 100644 (file)
@@ -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;
        }
 
index 001735e..888940a 100644 (file)
@@ -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;
                                        }
index 06203b8..bff62a5 100644 (file)
@@ -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']),
                ]);
        }
 
index 1165036..106705b 100644 (file)
@@ -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);
index 7c412ae..496bbfc 100644 (file)
@@ -53,7 +53,7 @@ class Widget
                        $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining'));
                        if ($x || is_site_admin()) {
                                DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
-                                       . L10n::tt('%d invitation available', '%d invitations available', $x)
+                                       . DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
                                        . '</div>';
                        }
                }
@@ -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'),
index 67f8d9a..fbb5683 100644 (file)
@@ -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)) {
index 561dec0..2e97c81 100644 (file)
@@ -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,
                ]);
index 67c0e47..7fc268a 100644 (file)
@@ -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
index 6868b45..d29e408 100644 (file)
@@ -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
index d48d179..c776741 100644 (file)
@@ -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) {
index ffee6ed..8ae32d0 100644 (file)
@@ -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.
index bb7868f..ed99a39 100644 (file)
@@ -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')],
index 543562d..2d38d59 100644 (file)
@@ -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'])) {
index 183a1bd..19e7363 100644 (file)
@@ -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');
index cdc5ac6..b467d14 100644 (file)
@@ -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 = [])
index afde70e..0e83f30 100644 (file)
@@ -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');
index a95b02d..968bab9 100644 (file)
@@ -61,7 +61,7 @@ class Verify extends BaseModule
 
                        '$title'            => DI::l10n()->t('Two-factor authentication'),
                        '$message'          => DI::l10n()->t('<p>Open the two-factor authentication app on your device to get an authentication code and verify your identity.</p>'),
-                       '$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? <a href="%s">Enter a two-factor recovery code</a>', '2fa/recovery'),
                        '$verify_code'      => ['verify_code', DI::l10n()->t('Please enter a code from your authentication app'), '', '', 'required', 'autofocus placeholder="000000"', 'tel'],
index efaa688..c49061e 100644 (file)
@@ -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'];