Amire80 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/56378


Change subject: (bug 39075) Refactor the message formulation
......................................................................

(bug 39075) Refactor the message formulation

Put the message formulation in a separate function
to make previewing easier.

Change-Id: I99b54e6b032bb6ffb88a77f3d0eda648b587467c
---
M SpecialNotifyTranslators.php
M TranslationNotifications.i18n.php
2 files changed, 45 insertions(+), 29 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslationNotifications 
refs/changes/78/56378/1

diff --git a/SpecialNotifyTranslators.php b/SpecialNotifyTranslators.php
index 0056a09..67f698a 100644
--- a/SpecialNotifyTranslators.php
+++ b/SpecialNotifyTranslators.php
@@ -156,9 +156,7 @@
        }
 
        /**
-        * Callback for the submit button.
-        *
-        * @todo Document
+        * Callback for the send button.
         */
        public function submitNotifyTranslatorsForm( $formData, $form ) {
                $this->translatablePageTitle = Title::newFromID( 
$formData['TranslatablePage'] );
@@ -517,21 +515,25 @@
        }
 
        /**
-        * Leave a message on the user's talk page.
+        * Formulate the text to add to the user page.
         * @param User $user To whom the message to be sent
         * @param string[] $languagesToNotify A list of languages that are 
notified. Empty for all languages.
         * @param string $destination Whether to send it to a talk page on this 
wiki ('talkpageHere', default)
         *               or another one ('talkpageInOtherWiki').
-        * @return boolean True if it was successful
+        * @return string
         */
-       public function leaveUserMessage(
+       protected function userTalkPageText(
                User $user,
                $languagesToNotify = array(),
-               $destination = 'talkpageHere' )
-       {
+               $destination = 'talkpageHere'
+       ) {
                $relevantLanguages = $this->getRelevantLanguages( $user, 
$languagesToNotify );
-               $userFirstLanguageCode = $this->getUserFirstLanguage( $user );
-               $userFirstLanguage = Language::factory( $userFirstLanguageCode 
);
+               $userFirstLanguage = Language::factory( 
$this->getUserFirstLanguage( $user ) );
+               $titleForMessage = $this->translatablePageTitle;
+               global $wgLocalInterwiki;
+               if ( $destination === 'talkpageInOtherWiki' && 
$wgLocalInterwiki !== false ) {
+                       $titleForMessage = 
":$wgLocalInterwiki:$titleForMessage|$titleForMessage";
+               }
 
                // Assume that the message is in the content language
                // of the originating wiki.
@@ -547,12 +549,7 @@
                        $this->notificationText
                );
 
-               global $wgLocalInterwiki;
-               $titleForMessage = $this->translatablePageTitle;
-               if ( $destination === 'talkpageInOtherWiki' && 
$wgLocalInterwiki !== false ) {
-                       $titleForMessage = 
":$wgLocalInterwiki:$titleForMessage|$titleForMessage";
-               }
-               $text = $this->msg(
+               return $this->msg(
                        'translationnotifications-talkpage-body',
                        $user->getName(),
                        $this->getUserName( $user ),
@@ -568,13 +565,30 @@
                        // Bidi-isolation of site name from date
                        . $userFirstLanguage->getDirMarkEntity()
                        . ', ~~~~~'; // Date and time
+       }
+
+       /**
+        * Leave a message on the user's talk page.
+        * @param User $user To whom the message to be sent
+        * @param string[] $languagesToNotify A list of languages that are 
notified. Empty for all languages.
+        * @param string $destination Whether to send it to a talk page on this 
wiki ('talkpageHere', default)
+        *               or another one ('talkpageInOtherWiki').
+        * @return boolean True if it was successful
+        */
+       public function leaveUserMessage(
+               User $user,
+               $languagesToNotify = array(),
+               $destination = 'talkpageHere' )
+       {
+               $userFirstLanguageCode = $this->getUserFirstLanguage( $user );
+               $userFirstLanguage = Language::factory( $userFirstLanguageCode 
);
 
                $editSummary = $this->msg(
                        'translationnotifications-edit-summary',
                        $this->translatablePageTitle
                )->inLanguage( $userFirstLanguage )->text();
                $params = array(
-                       'text' => $text,
+                       'text' => $this->userTalkPageText( $user, 
$languagesToNotify, $destination ),
                        'editSummary' => $editSummary,
                        'editor' => $this->getUser()->getId(),
                        'languageCode' => $userFirstLanguageCode,
diff --git a/TranslationNotifications.i18n.php 
b/TranslationNotifications.i18n.php
index 842479d..ff2348c 100644
--- a/TranslationNotifications.i18n.php
+++ b/TranslationNotifications.i18n.php
@@ -72,6 +72,7 @@
 as a truly multilingual community.
 
 Thank you!
+
 {{SITENAME}} translation coordinators
 
 ----
@@ -80,7 +81,8 @@
        'translationnotifications-talkpage-body' => 'Hello $2,
 
 You are receiving this notification because you {{GENDER:$1|signed up}} as a 
translator {{PLURAL:$9|to}} $3 on {{SITENAME}}.
-The page [[$4]] is available for translation. You can translate it here:
+There is a page to translate there: [[$4]].
+You can translate it by clicking the following link:
 $5
 
 $6
@@ -1787,7 +1789,7 @@
 
 $8
 
-Waša pomoc je jara witana. Přełožowarjo kaž ty pomhaja, zo by {{SITENAME}} kaž 
woprawdźe wjacerěčne zhromadźenstwo fungowało.  
+Waša pomoc je jara witana. Přełožowarjo kaž ty pomhaja, zo by {{SITENAME}} kaž 
woprawdźe wjacerěčne zhromadźenstwo fungowało.
 
 Wulki dźak!
 
@@ -2561,7 +2563,7 @@
 
 $7
 
-Вашата помош многу ни значи. Благодарение на преведувачите како вас, 
{{SITENAME}} 
+Вашата помош многу ни значи. Благодарение на преведувачите како вас, 
{{SITENAME}}
 функционира како вистинска повеќејазична заедница.
 
 Ви благодариме!
@@ -2583,7 +2585,7 @@
 $8
 
 
-Вашата помош многу ни значи. Благодарение на преведувачите како вас, 
{{SITENAME}} 
+Вашата помош многу ни значи. Благодарение на преведувачите како вас, 
{{SITENAME}}
 функционира како вистинска повеќејазична заедница.
 
 Ви благодариме!
@@ -2599,7 +2601,7 @@
 
 $4
 
-Вашата помош многу ни значи. Благодарение на преведувачите како вас, 
{{SITENAME}} 
+Вашата помош многу ни значи. Благодарение на преведувачите како вас, 
{{SITENAME}}
 функционира како вистинска повеќејазична заедница.
 
 Ви благодариме!
@@ -4012,11 +4014,11 @@
 
 $7
 
-Talagang ikinalulugod ang iyong pagtulong. Ang mga tagapagsalinwikang katulad 
mo ay nakakatulong sa {{SITENAME}} upang tumakbo 
+Talagang ikinalulugod ang iyong pagtulong. Ang mga tagapagsalinwikang katulad 
mo ay nakakatulong sa {{SITENAME}} upang tumakbo
 bilang isang tunay na pamayanan ng maramihang mga wika.
 
 Salamat sa iyo!
-Mga tagapangasiwa ng salinwika ng {{SITENAME}} 
+Mga tagapangasiwa ng salinwika ng {{SITENAME}}
 
 ----
 
@@ -4032,7 +4034,7 @@
 
 $8
 
-Talagang ikinalulugod ang iyong pagtulong. Ang mga tagapagsalinwikang katulad 
mo ay nakakatulong sa {{SITENAME}}  upang tumakbo 
+Talagang ikinalulugod ang iyong pagtulong. Ang mga tagapagsalinwikang katulad 
mo ay nakakatulong sa {{SITENAME}}  upang tumakbo
 bilang isang tunay na pamayanan ng maramihang mga wika.
 
 Salamat sa iyo!
@@ -4048,11 +4050,11 @@
 
 $4
 
-Talagang ikinalulugod ang iyong pagtulong. Ang mga tagapagsalinwikang katulad 
mo ay nakakatulong sa {{SITENAME}} upang mapatakbo 
+Talagang ikinalulugod ang iyong pagtulong. Ang mga tagapagsalinwikang katulad 
mo ay nakakatulong sa {{SITENAME}} upang mapatakbo
 bilang isang tunay na pamayanan ng maramihang mga wika.
 
 Salamat sa iyo!
-Mga tagapangasiwa ng salinwika ng {{SITENAME}} 
+Mga tagapangasiwa ng salinwika ng {{SITENAME}}
 
 ----
 
@@ -4143,7 +4145,7 @@
        'translationnotifications-translatablepage-title' => 'Назва сторінки 
для перекладу:',
        'translationnotifications-error-no-translatable-pages' => 'У цій Вікі 
немає сторінок для перекладу.',
        'translationnotifications-email-subject' => 'Будь ласка, перекладіть 
сторінку $1',
-       'translationnotifications-email-body' => 'Привіт,  $1. 
+       'translationnotifications-email-body' => 'Привіт,  $1.
 
 Ви отримали цього листа, тому що на {{SITENAME}} ви 
{{GENDER:$10|зареєструвалися}} на {{SITENAME}} як перекладач {{PLURAL:$9|такими 
мовами}}: $2.
 
@@ -4181,7 +4183,7 @@
 Координатори перекладів {{SITENAME}}',
        'translationnotifications-notification-url-listitem' => 'Перекласти 
мовою $1',
        'translationnotifications-digestemail-subject' => 'Дайджест 
повідомлення електронною поштою із запитами перекладу  від {{SITENAME}}',
-       'translationnotifications-digestemail-body' => 'Привіт,  $1. 
+       'translationnotifications-digestemail-body' => 'Привіт,  $1.
 
 Ви отримали цього листа, тому що ви {{GENDER:$1|зареєструвалися}} на 
{{SITENAME}} як перекладач на такі мови: $2.
 

-- 
To view, visit https://gerrit.wikimedia.org/r/56378
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I99b54e6b032bb6ffb88a77f3d0eda648b587467c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TranslationNotifications
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to