diff --git a/extension.json b/extension.json index 93a189fd0..628f5638b 100644 --- a/extension.json +++ b/extension.json @@ -193,6 +193,13 @@ "ModeTabOptionWidget.js", "AbandonCommentDialog.js", "AbandonTopicDialog.js", + { + "name": "contLangMessages.json", + "callback": "\\MediaWiki\\Extension\\DiscussionTools\\ResourceLoaderData::getContentLanguageMessages", + "callbackParam": [ + "tempuser-helppage" + ] + }, { "name": "licenseMessages.json", "callback": "\\MediaWiki\\Extension\\DiscussionTools\\ResourceLoaderData::getTermsOfUseMessagesParsed", @@ -211,6 +218,7 @@ "discussiontools-replywidget-abandontopic-keep", "discussiontools-replywidget-advanced", "discussiontools-replywidget-anon-warning", + "discussiontools-replywidget-autocreate-warning", "discussiontools-replywidget-cancel", "discussiontools-replywidget-feedback", "discussiontools-replywidget-mention-tool-header", diff --git a/i18n/en.json b/i18n/en.json index 16d533931..970b366a6 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -117,6 +117,7 @@ "discussiontools-replywidget-abandontopic-keep": "Continue writing", "discussiontools-replywidget-advanced": "Advanced", "discussiontools-replywidget-anon-warning": "You are not logged in. To be notified when someone replies and receive attribution with your name instead of your IP address, you can [$1 log in] or [$2 create an account].", + "discussiontools-replywidget-autocreate-warning": "You are not logged in. To be notified when someone replies and receive attribution with a name of your choice instead of an [[$3|auto-generated name]], you can [$1 log in] or [$2 create an account].", "discussiontools-replywidget-cancel": "Cancel", "discussiontools-replywidget-feedback": "{{GENDER:|Share feedback}} about this feature", "discussiontools-replywidget-feedback-link": "https://www.mediawiki.org/wiki/Talk:Talk_pages_project/Replying", diff --git a/i18n/qqq.json b/i18n/qqq.json index 8b654957e..d9df391e0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -131,6 +131,7 @@ "discussiontools-replywidget-abandontopic-keep": "Label for button to cancel abandoning a new topic\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandontopic}}.\n\nSimilar to {{msg-mw|discussiontools-replywidget-abandon-keep}}.", "discussiontools-replywidget-advanced": "Label for button to toggle the advanced options, which shows an edit summary input and watchlist checkbox.", "discussiontools-replywidget-anon-warning": "Warning message to be displayed when anonymous user starts writing a new topic or reply.\n* $1 is a URL to log in.\n* $2 is a URL to register an account.", + "discussiontools-replywidget-autocreate-warning": "Warning message to be displayed when anonymous user starts writing a new topic or reply, and temporary user auto-creation is enabled.\n* $1 is a URL to log in.\n* $2 is a URL to register an account.\n* $3 is a link to the documentation page for temporary accounts.", "discussiontools-replywidget-cancel": "Label for the cancel button to exit out of the widget\n\n{{Identical|Cancel}}", "discussiontools-replywidget-feedback": "Label for link to share feedback about the reply widget", "discussiontools-replywidget-feedback-link": "{{optional|Link to a page where users can share feedback about the reply widget. Defaults to a page on MediaWiki.org.}}", diff --git a/modules/CommentDetails.js b/modules/CommentDetails.js index 26ec138b6..54c17ee68 100644 --- a/modules/CommentDetails.js +++ b/modules/CommentDetails.js @@ -7,13 +7,16 @@ * @param {number} oldId Revision ID of page at time of editing * @param {Object.} notices Edit notices for the page where the reply is being saved. * Keys are message names; values are HTML to display. + * @param {boolean} wouldAutoCreate Whether saving the comment would automatically create a + * temporary account if the user is logged out * @param {string} preloadContent Preload content, may be wikitext or HTML depending on `preloadContentMode` * @param {string} preloadContentMode 'source' or 'visual' */ -function CommentDetails( pageName, oldId, notices, preloadContent, preloadContentMode ) { +function CommentDetails( pageName, oldId, notices, wouldAutoCreate, preloadContent, preloadContentMode ) { this.pageName = pageName; this.oldId = oldId; this.notices = notices; + this.wouldAutoCreate = wouldAutoCreate; this.preloadContent = preloadContent; this.preloadContentMode = preloadContentMode; } diff --git a/modules/controller.js b/modules/controller.js index 3163ca9a7..44d005791 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -214,7 +214,7 @@ function checkThreadItemOnPage( pageName, oldId, threadItem ) { } ] } ).promise(); } - return new CommentDetails( pageName, oldId, metadata.notices, metadata.content, defaultMode ); + return new CommentDetails( pageName, oldId, metadata.notices, metadata.wouldautocreate, metadata.content, defaultMode ); } ); } diff --git a/modules/dt.ui.ReplyWidget.js b/modules/dt.ui.ReplyWidget.js index 1ed4a1521..6419ad2bf 100644 --- a/modules/dt.ui.ReplyWidget.js +++ b/modules/dt.ui.ReplyWidget.js @@ -2,6 +2,7 @@ var controller = require( 'ext.discussionTools.init' ).controller, utils = require( 'ext.discussionTools.init' ).utils, ModeTabSelectWidget = require( './ModeTabSelectWidget.js' ), ModeTabOptionWidget = require( './ModeTabOptionWidget.js' ), + contLangMessages = require( './contLangMessages.json' ), licenseMessages = require( './licenseMessages.json' ), featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ) || {}, enable2017Wikitext = featuresEnabled.sourcemodetoolbar, @@ -267,6 +268,9 @@ function ReplyWidget( commentController, commentDetails, config ) { } if ( mw.user.isAnon() ) { + var msg = this.commentDetails.wouldAutoCreate ? + 'discussiontools-replywidget-autocreate-warning' : + 'discussiontools-replywidget-anon-warning'; var returnTo = { returntoquery: window.location.search.slice( 1 ), returnto: mw.config.get( 'wgPageName' ) @@ -274,10 +278,12 @@ function ReplyWidget( commentController, commentDetails, config ) { this.anonWarning = new OO.ui.MessageWidget( { classes: [ 'ext-discussiontools-ui-replyWidget-anonWarning' ], type: 'warning', - label: mw.message( 'discussiontools-replywidget-anon-warning' ) + // eslint-disable-next-line mediawiki/msg-doc + label: mw.message( msg ) .params( [ mw.util.getUrl( 'Special:Userlogin', returnTo ), - mw.util.getUrl( 'Special:Userlogin/signup', returnTo ) + mw.util.getUrl( 'Special:Userlogin/signup', returnTo ), + contLangMessages[ 'tempuser-helppage' ] ] ) .parseDom() } );