Amire80 has uploaded a new change for review. https://gerrit.wikimedia.org/r/56914
Change subject: (bug 39075) Add a 'Preview' button to the notification form ...................................................................... (bug 39075) Add a 'Preview' button to the notification form Change-Id: I803484ca2eb768d89d4c6b8172e6aa14b7c3884a --- M TranslationNotifications.i18n.php M TranslationNotifications.php M resources/ext.translationnotifications.notifytranslators.js 3 files changed, 96 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TranslationNotifications refs/changes/14/56914/1 diff --git a/TranslationNotifications.i18n.php b/TranslationNotifications.i18n.php index e6e7e5e..8bcc416 100644 --- a/TranslationNotifications.i18n.php +++ b/TranslationNotifications.i18n.php @@ -44,6 +44,7 @@ 'notifytranslators' => 'Notify translators', 'translationnotifications-submit-ok' => 'Notifications have been added to a queue and are delivered by a background job.', 'translationnotifications-send-notification-button' => 'Send a notification to translators', + 'translationnotifications-preview-notification-button' => 'Preview the notification', 'translationnotifications-deadline-label' => 'Deadline to indicate in this notification:', 'translationnotifications-languages-to-notify-label' => 'Which languages to notify:', 'translationnotifications-languages-to-notify-label-help-message' => 'Comma-separated language codes; leave blank to notify for all languages.', @@ -124,7 +125,9 @@ 'translationnotifications-sent-body' => 'Translation notification was sent.', 'translationnotifications-log-alllanguages' => 'all languages', 'translationnotifications-nodeadline' => 'none', - 'translationnotifications-signup-legal' => 'You agree that by providing this information we may contact you regarding topics related to {{SITENAME}} we think may be of interest to you. You agree your data is subject to our [[{{MediaWiki:Privacypage}}|privacy policy]].' + 'translationnotifications-signup-legal' => 'You agree that by providing this information we may contact you regarding topics related to {{SITENAME}} we think may be of interest to you. You agree your data is subject to our [[{{MediaWiki:Privacypage}}|privacy policy]].', + + 'translationnotifications-generic-languages' => '<languages>', ); /** Message documentation (Message documentation) @@ -169,6 +172,7 @@ 'translationnotifications-signup-success' => 'A message that appears on the top of Special:TranslatorSignup after saving the preferences.', 'notifytranslators' => '{{doc-special|NotifyTranslators}}', 'translationnotifications-send-notification-button' => 'A title for the submit button of the translator notification form.', + 'translationnotifications-preview-notification-button' => 'A title for the preview button. Pressing the button shows the previewed notification below the form.', 'translationnotifications-deadline-label' => 'A label for the deadline field, which will have a datepicker.', 'translationnotifications-languages-to-notify-label' => 'A label for language codes field.', 'translationnotifications-priority' => 'A label for translation priority field. @@ -194,7 +198,7 @@ * $9 - Number of languages. Can be used in PLURAL. * $10- Plain text username used for GENDER.", 'translationnotifications-talkpage-body' => "The body of the notification on user talk page. - +* $1 - Plain user name, can be used for GENDER. * $2 - Translator's username or real name, if specified. * $3 - A comma list of language names. * $4 - Translatable page name. @@ -236,6 +240,7 @@ 'translationnotifications-nodeadline' => 'Appears in the log message, saying that no deadline was specified. Traduction en français : "aucune" (date limite). {{Identical|None}}', 'translationnotifications-signup-legal' => 'Legal text shown at the bottom of [[Special:TranslatorSignup]] page.', + 'translationnotifications-generic-languages' => 'A generic placeholder that is shown in the previewed notification instead of a list of language names.', ); /** Arabic (العربية) @@ -1626,6 +1631,7 @@ 'notifytranslators' => 'מכתבים למתרגמים', 'translationnotifications-submit-ok' => 'ההודעות נוספו לתור המשימות ויישלחו על־ידי משימת רקע.', 'translationnotifications-send-notification-button' => 'שליחת מכתבים למתרגמים', + 'translationnotifications-preview-notification-button' => 'תצוגה מקדימה', 'translationnotifications-deadline-label' => 'תאריך סופי שיתווסף להודעה:', 'translationnotifications-languages-to-notify-label' => 'רשימת שפות שהמתרגמים אליהן יקבלו את ההודעה:', 'translationnotifications-languages-to-notify-label-help-message' => 'רשימה מופרדת בפסיקים של קודי שפה; אם השדה יהיה ריק, ההודעה תישלח לדוברי כל השפות.', @@ -1708,6 +1714,7 @@ 'translationnotifications-log-alllanguages' => 'כל השפות', 'translationnotifications-nodeadline' => 'אין', 'translationnotifications-signup-legal' => 'מתן המידע הזה מהווה את הסכמתך לכך שניצור אתך קשר בנושאים שקשורים לאתר {{SITENAME}} ושנראה לנו שיעניינו אותך. הנתונים שלך כפופים ל[[{{MediaWiki:Privacypage}}|מדיניות הפרטיות]] שלנו.', + 'translationnotifications-generic-languages' => '<שפות>', ); /** Upper Sorbian (hornjoserbsce) @@ -1787,7 +1794,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 +2568,7 @@ $7 -Вашата помош многу ни значи. Благодарение на преведувачите како вас, {{SITENAME}} +Вашата помош многу ни значи. Благодарение на преведувачите како вас, {{SITENAME}} функционира како вистинска повеќејазична заедница. Ви благодариме! @@ -2583,7 +2590,7 @@ $8 -Вашата помош многу ни значи. Благодарение на преведувачите како вас, {{SITENAME}} +Вашата помош многу ни значи. Благодарение на преведувачите како вас, {{SITENAME}} функционира како вистинска повеќејазична заедница. Ви благодариме! @@ -2599,7 +2606,7 @@ $4 -Вашата помош многу ни значи. Благодарение на преведувачите како вас, {{SITENAME}} +Вашата помош многу ни значи. Благодарение на преведувачите како вас, {{SITENAME}} функционира како вистинска повеќејазична заедница. Ви благодариме! @@ -4012,11 +4019,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 +4039,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 +4055,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 +4150,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 +4188,7 @@ Координатори перекладів {{SITENAME}}', 'translationnotifications-notification-url-listitem' => 'Перекласти мовою $1', 'translationnotifications-digestemail-subject' => 'Дайджест повідомлення електронною поштою із запитами перекладу від {{SITENAME}}', - 'translationnotifications-digestemail-body' => 'Привіт, $1. + 'translationnotifications-digestemail-body' => 'Привіт, $1. Ви отримали цього листа, тому що ви {{GENDER:$1|зареєструвалися}} на {{SITENAME}} як перекладач на такі мови: $2. diff --git a/TranslationNotifications.php b/TranslationNotifications.php index 16d7c7e..4912ee5 100644 --- a/TranslationNotifications.php +++ b/TranslationNotifications.php @@ -54,9 +54,21 @@ $wgResourceModules['ext.translationnotifications.notifytranslators'] = array( 'scripts' => 'resources/ext.translationnotifications.notifytranslators.js', 'dependencies' => array( + 'mediawiki.jqueryMsg', + 'mediawiki.Uri', + 'mediawiki.api', + 'mediawiki.api.parse', + 'mediawiki.user', 'jquery.ui.datepicker', 'ext.translate.multiselectautocomplete', ), + 'messages' => array( + 'translationnotifications-preview-notification-button', + 'translationnotifications-talkpage-body', + 'translationnotifications-generic-languages', + 'translationnotifications-email-priority', + 'translationnotifications-email-deadline', + ), ) + $resourcePaths; $wgTranslationNotificationsContactMethods = array( diff --git a/resources/ext.translationnotifications.notifytranslators.js b/resources/ext.translationnotifications.notifytranslators.js index 02dafe8..27811b7 100644 --- a/resources/ext.translationnotifications.notifytranslators.js +++ b/resources/ext.translationnotifications.notifytranslators.js @@ -7,10 +7,13 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ -jQuery( document ).ready( function( $ ) { +jQuery( document ).ready( function( $, mw ) { 'use strict'; - // Based on UploadWizard + var previewId = 'translation-notification-preview'; + + // Show a datepicker. + // Based on UploadWizard. $( '#mw-input-wpDeadlineDate' ).datepicker( { dateFormat: 'yy-mm-dd', constrainInput: false, @@ -31,5 +34,62 @@ } } ); - $( "#wpUserLanguage" ).multiselectautocomplete( { inputbox : '#mw-input-wpLanguagesToNotify' } ); -} ); + // Attach the language autocomplete widget. + $( '#wpUserLanguage' ).multiselectautocomplete( { inputbox : '#mw-input-wpLanguagesToNotify' } ); + + /** + * Notification preview + */ + // Add the preview button + + $( '#notifytranslators-form' ).after( + $( '<button>' ) + .text( mw.msg( 'translationnotifications-preview-notification-button' ) ) + .click( function () { + var fullText, + uri = new mw.Uri(), + priority = '', + deadline = '', + translatablePage = $( '#mw-input-wpTranslatablePage :selected' ).text(), + userName = mw.user.getName(), + $priority = $( '#mw-input-wpPriority :selected' ), + deadlineDate = $( '#mw-input-wpDeadlineDate' ).val(); + + uri.path = mw.config.get( 'wgScript' ); + uri.query = { + title: 'Special:Translate', + group: 'page-' + translatablePage + }; + + if ( $priority.val() !== 'unset' ) { + priority = mw.msg( 'translationnotifications-email-priority', $priority.text() ); + } + + if ( deadlineDate !== '' ) { + deadline = mw.msg( 'translationnotifications-email-deadline', deadlineDate ); + } + + fullText = mw.message( 'translationnotifications-talkpage-body', + userName, + userName, + mw.msg( 'translationnotifications-generic-languages' ), + translatablePage, + '[' + uri.toString() + ' ' + translatablePage + ']', + priority, + deadline, + $( '#mw-input-wpNotificationText' ).val(), + 1 // it's just an example, so provide one language + ); + + new mw.Api().parse( fullText.escaped() ) + .done( function ( parsedNotification ) { + $( '#' + previewId ) + .html( parsedNotification ) + .show(); + } ); + } ), + $( '<div>' ) + .hide() + .attr( { id: previewId } ) + ); +}( jQuery, mediaWiki ) ); -- To view, visit https://gerrit.wikimedia.org/r/56914 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I803484ca2eb768d89d4c6b8172e6aa14b7c3884a 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