Add an optional suffix message to mentions

Wikis like jawiki will then be able to customize the message to include
honorifics as they think appropriate.

Bug: T268588
Change-Id: I213fb9fd0a9ed6592ce3548a5b2c3b11a55c1abc
This commit is contained in:
David Lynch 2022-01-19 10:29:10 -06:00
parent 7694243a9f
commit dccaa5bf65
6 changed files with 12 additions and 3 deletions

View file

@ -48,6 +48,7 @@
"discussiontools-replywidget-feedback-link", "discussiontools-replywidget-feedback-link",
"discussiontools-replywidget-feedback-link-newtopic", "discussiontools-replywidget-feedback-link-newtopic",
"discussiontools-replywidget-mention-prefix", "discussiontools-replywidget-mention-prefix",
"discussiontools-replywidget-mention-suffix",
"discussiontools-signature-prefix" "discussiontools-signature-prefix"
] ]
}, },

View file

@ -78,6 +78,7 @@
"discussiontools-replywidget-feedback-link-newtopic": "https://www.mediawiki.org/wiki/Talk:Talk_pages_project/New_discussion", "discussiontools-replywidget-feedback-link-newtopic": "https://www.mediawiki.org/wiki/Talk:Talk_pages_project/New_discussion",
"discussiontools-replywidget-loading": "Loading…", "discussiontools-replywidget-loading": "Loading…",
"discussiontools-replywidget-mention-prefix": "@", "discussiontools-replywidget-mention-prefix": "@",
"discussiontools-replywidget-mention-suffix": "",
"discussiontools-replywidget-mention-tool-header": "Find user: $1", "discussiontools-replywidget-mention-tool-header": "Find user: $1",
"discussiontools-replywidget-mention-tool-title": "Mention a user", "discussiontools-replywidget-mention-tool-title": "Mention a user",
"discussiontools-replywidget-mode-source": "Source", "discussiontools-replywidget-mode-source": "Source",

View file

@ -88,6 +88,7 @@
"discussiontools-replywidget-feedback-link-newtopic": "{{notranslate}}\nLink to a page where users can share feedback about the new topic widget. Defaults to a page on MediaWiki.org.", "discussiontools-replywidget-feedback-link-newtopic": "{{notranslate}}\nLink to a page where users can share feedback about the new topic widget. Defaults to a page on MediaWiki.org.",
"discussiontools-replywidget-loading": "Message shown while the reply widget is loading", "discussiontools-replywidget-loading": "Message shown while the reply widget is loading",
"discussiontools-replywidget-mention-prefix": "{{optional|Character to prefix mentions. This does not have to be the same as the trigger character, which is always '@'.}}", "discussiontools-replywidget-mention-prefix": "{{optional|Character to prefix mentions. This does not have to be the same as the trigger character, which is always '@'.}}",
"discussiontools-replywidget-mention-suffix": "{{optional|Character to suffix mentions. This is intended for community customization in languages with honorifics.}}",
"discussiontools-replywidget-mention-tool-header": "Header of search results when searching for a user to mention.\n\nParameters:\n* $1 search query for the username. Note that this is not a full username, and '''can't''' be used with <code><nowiki>{{GENDER:}}</nowiki></code>.", "discussiontools-replywidget-mention-tool-header": "Header of search results when searching for a user to mention.\n\nParameters:\n* $1 search query for the username. Note that this is not a full username, and '''can't''' be used with <code><nowiki>{{GENDER:}}</nowiki></code>.",
"discussiontools-replywidget-mention-tool-title": "Title text for the user mention tool.", "discussiontools-replywidget-mention-tool-title": "Title text for the user mention tool.",
"discussiontools-replywidget-mode-source": "Label for the widget's source mode.\n\nThis should not include the word 'edit' or 'editor', and where possible should avoid 'wikitext' which is MediaWiki-specific terminology.", "discussiontools-replywidget-mode-source": "Label for the widget's source mode.\n\nThis should not include the word 'edit' or 'editor', and where possible should avoid 'wikitext' which is MediaWiki-specific terminology.",

View file

@ -50,6 +50,7 @@ CeMWPingNode.static.getDescription = function ( model ) {
CeMWPingNode.prototype.initialize = function () { CeMWPingNode.prototype.initialize = function () {
var model = this.getModel(), var model = this.getModel(),
prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ), prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
user = model.getAttribute( 'user' ), user = model.getAttribute( 'user' ),
title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, user ); title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, user );
@ -72,7 +73,8 @@ CeMWPingNode.prototype.initialize = function () {
this.$element.append( this.$element.append(
prefix, prefix,
$link $link,
suffix
); );
}; };

View file

@ -49,6 +49,7 @@ DmMWPingNode.static.disallowedAnnotationTypes = [ 'link' ];
DmMWPingNode.static.toDomElements = function ( dataElement, doc, converter ) { DmMWPingNode.static.toDomElements = function ( dataElement, doc, converter ) {
var domElements, var domElements,
prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ), prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, dataElement.attributes.user ); title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, dataElement.attributes.user );
dataElement = ve.dm.MWInternalLinkAnnotation.static.dataElementFromTitle( title ); dataElement = ve.dm.MWInternalLinkAnnotation.static.dataElementFromTitle( title );
@ -56,8 +57,10 @@ DmMWPingNode.static.toDomElements = function ( dataElement, doc, converter ) {
domElements[ 0 ].appendChild( domElements[ 0 ].appendChild(
doc.createTextNode( title.getMainText() ) doc.createTextNode( title.getMainText() )
); );
domElements.unshift( document.createTextNode( prefix ) );
domElements.push( document.createTextNode( suffix ) );
return [ document.createTextNode( prefix ) ].concat( domElements ); return domElements;
}; };
// toDataElement should never be called for this node // toDataElement should never be called for this node

View file

@ -156,11 +156,12 @@ MWUsernameCompletionAction.prototype.getHeaderLabel = function ( input, suggesti
MWUsernameCompletionAction.prototype.insertCompletion = function ( word, range ) { MWUsernameCompletionAction.prototype.insertCompletion = function ( word, range ) {
var prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ), var prefix = mw.msg( 'discussiontools-replywidget-mention-prefix' ),
suffix = mw.msg( 'discussiontools-replywidget-mention-suffix' ),
title = mw.Title.newFromText( word, mw.config.get( 'wgNamespaceIds' ).user ); title = mw.Title.newFromText( word, mw.config.get( 'wgNamespaceIds' ).user );
if ( this.surface.getMode() === 'source' ) { if ( this.surface.getMode() === 'source' ) {
// TODO: this should be configurable per-wiki so that e.g. custom templates can be used // TODO: this should be configurable per-wiki so that e.g. custom templates can be used
word = prefix + '[[' + title.getPrefixedText() + '|' + word + ']]'; word = prefix + '[[' + title.getPrefixedText() + '|' + word + ']]' + suffix;
return MWUsernameCompletionAction.super.prototype.insertCompletion.call( this, word, range ); return MWUsernameCompletionAction.super.prototype.insertCompletion.call( this, word, range );
} }