highlighter: Show a different message for missing heading links

These are not widely used anywhere, but linking to an #h- heading ID
that doesn't exist should say "topic not found" rather than
"comment not found".

Change-Id: Ifd269cc72e640f36431f85c751874ca06229ba9f
This commit is contained in:
Ed Sanders 2023-10-28 15:28:30 +01:00
parent cb26bb912f
commit f2265f918f
4 changed files with 8 additions and 1 deletions

View file

@ -142,6 +142,7 @@
"discussiontools-replywidget-loading",
"discussiontools-replywidget-watchthis",
"discussiontools-target-comment-missing",
"discussiontools-target-heading-missing",
"discussiontools-target-comments-missing",
"discussiontools-topicsubscription-button-subscribe",
"discussiontools-topicsubscription-button-subscribe-label",

View file

@ -155,6 +155,7 @@
"discussiontools-signature-prefix": " ",
"discussiontools-target-comment-missing": "This comment could not be found. It might have been deleted or moved.",
"discussiontools-target-comments-missing": "New comments could not be found. They might have been deleted or moved.",
"discussiontools-target-heading-missing": "This topic could not be found. It might have been deleted or moved.",
"discussiontools-topicheader-authorcount": "$1 {{PLURAL:$1|person|people}} in discussion",
"discussiontools-topicheader-commentcount": "$1 {{PLURAL:$1|comment|comments}}",
"discussiontools-topicheader-latestcomment": "Latest comment: $1",

View file

@ -169,6 +169,7 @@
"discussiontools-signature-prefix": "{{optional}}\nWikitext that prefixes the signature. The prefix and signature will be appended directly to the message, so this must include a leading space if a gap is desired.\n\nThis message intentionally doesn't use the prefix from {{msg-mw|sig-text}}, because it is not actually commonly used on many wikis, but you can include it in the translation if that is the convention in your language.\n{{Format|plain}}",
"discussiontools-target-comment-missing": "Message shown in a popup when the user follows a link that would highlight a '''single''' comment on a talk page, e.g. [https://en.wikipedia.org/wiki/User_talk:Example#c-Example1-20190626080000], but the comment doesn't exist on the page any more. Such links are used in notifications, or can be used in comments by other users.\n\nSee also for multiple comments: {{msg-mw|discussiontools-target-comments-missing}}",
"discussiontools-target-comments-missing": "Message shown in a popup when the user follows a link that would highlight potentially '''multiple new''' comments on a talk page, but the exact number is unknown, e.g. [https://en.wikipedia.org/w/index.php?title=User_talk:Example&dtnewcommentssince=c-Example1-2019-06-26T10:20:00.000Z-Example2-2019-06-26T10:10:00.000Z], but none of these comments exist on the page any more. Such links are generated by notifications.\n\nSee also for a single comments: {{msg-mw|discussiontools-target-comment-missing}}",
"discussiontools-target-heading-missing": "Message shown in a popup when the user follows a link that would highlight a topic heading on a talk page, e.g. [https://en.wikipedia.org/wiki/User_talk:Example#h-Example_discussion_title-2019-06-26T08:00:00.000Z], but the topic heading doesn't exist on the page any more. Such links can be used in comments by other users.\n\nSee also for comments: {{msg-mw|discussiontools-target-comment-missing}}, {{msg-mw|discussiontools-target-comments-missing}}",
"discussiontools-topicheader-authorcount": "Label showing how many users have commented in a discussion.",
"discussiontools-topicheader-commentcount": "Label showing how many comments have been posted in a discussion. for languages without plural counters, just apply <nowiki> {{PLURAL:$1|[''comment''_in_your_language]}}</nowiki>, but never delete the template or it triggers error alert.",
"discussiontools-topicheader-latestcomment": "Label showing when the most recent comment was posted in a discussion. Parameters:\n* $1 When the comment was posted, e.g. '1 hour ago'. This text is a link to the comment.",

View file

@ -199,9 +199,13 @@ function highlightTargetComment( threadItemSet, noScroll ) {
}
if ( location.hash.match( /^#(c|h)-/ ) && !targetElement ) {
var isHeading = location.hash.slice( 1, 2 ) === 'h';
missingTargetNotifPromise = mw.loader.using( 'mediawiki.notification' ).then( function () {
return mw.notification.notify(
mw.message( 'discussiontools-target-comment-missing' ).text(),
mw.message( isHeading ?
'discussiontools-target-heading-missing' :
'discussiontools-target-comment-missing'
).text(),
{ type: 'warn', autoHide: false }
);
} );