jenkins-bot has submitted this change and it was merged.
Change subject: Use TitleGetEditNotices hook for showing edit notice instead of
AlternateEdit
......................................................................
Use TitleGetEditNotices hook for showing edit notice instead of AlternateEdit
Instead of modifying EditPage properties, use the proper hook for doing this.
This code is also now run only when page translation is enabled.
Change-Id: I455d7b6aee53073b78f4615e997e5cbf991c1a4a
---
M TranslateEditAddons.php
M TranslateHooks.php
M i18n/core/en.json
M i18n/core/qqq.json
M i18n/pagetranslation/en.json
M i18n/pagetranslation/qqq.json
M tag/PageTranslationHooks.php
7 files changed, 21 insertions(+), 12 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/TranslateEditAddons.php b/TranslateEditAddons.php
index cbbe9f7..a4bdb19 100644
--- a/TranslateEditAddons.php
+++ b/TranslateEditAddons.php
@@ -32,16 +32,6 @@
return false;
}
-
- return true;
- }
- $msg = wfMessage( 'translate-edit-tag-warning'
)->inContentLanguage();
-
- if ( !$msg->isDisabled() &&
- TranslatablePage::isSourcePage( $editpage->getTitle() )
- ) {
- $editpage->editFormTextTop .=
$editpage->getArticle()->getContext()
- ->getOutput()->parse( $msg->plain() );
}
return true;
diff --git a/TranslateHooks.php b/TranslateHooks.php
index 4fe736a..96072c7 100644
--- a/TranslateHooks.php
+++ b/TranslateHooks.php
@@ -174,6 +174,9 @@
// Our custom header for translation pages
$wgHooks['ArticleViewHeader'][] =
'PageTranslationHooks::translatablePageHeader';
+ // Edit notice shown on translatable pages
+ $wgHooks['TitleGetEditNotices'][] =
'PageTranslationHooks::onTitleGetEditNotices';
+
// Custom move page that can move all the associated
pages too
$wgHooks['SpecialPage_initList'][] =
'PageTranslationHooks::replaceMovePage';
// Locking during page moves
diff --git a/i18n/core/en.json b/i18n/core/en.json
index 5f0e514..2eef639 100644
--- a/i18n/core/en.json
+++ b/i18n/core/en.json
@@ -61,7 +61,6 @@
"translate-use-suggestion": "Replace current translation with this
suggestion.",
"translate-edit-nopermission": "You need translation rights to
translate messages.",
"translate-edit-askpermission": "Get permission",
- "translate-edit-tag-warning": "",
"exporttranslations": "Export translations",
"translate-export-form-format": "Format",
"translate-export-invalid-format": "Please specify a valid format.",
diff --git a/i18n/core/qqq.json b/i18n/core/qqq.json
index 05f5ea8..4dd13dd 100644
--- a/i18n/core/qqq.json
+++ b/i18n/core/qqq.json
@@ -92,7 +92,6 @@
"translate-use-suggestion": "Used as a tooltip for the \"down arrow\"
to insert translation suggestions in the translation edit page.",
"translate-edit-nopermission": "Followed by link text
{{msg-mw|Translate-edit-askpermission}}.",
"translate-edit-askpermission": "Used as link text.\n\nPreceded by
{{msg-mw|Translate-edit-nopermission}}.",
- "translate-edit-tag-warning": "{{notranslate}}\nShown when editing
translatable pages. Default is empty.",
"exporttranslations": "Title of [[Special:ExportTranslations]]",
"translate-export-form-format": "Label of form field on
[[Special:ExportTranslations]].\n{{Identical|Format}}",
"translate-export-invalid-format": "Validation error shown on
[[Special:ExportTranslations]].",
diff --git a/i18n/pagetranslation/en.json b/i18n/pagetranslation/en.json
index 14beae9..cfe8210 100644
--- a/i18n/pagetranslation/en.json
+++ b/i18n/pagetranslation/en.json
@@ -52,6 +52,7 @@
"tpt-rev-unmark-tooltip": "Remove this page from translation.",
"tpt-rev-discourage-tooltip": "Discourage further translations on this
page.",
"tpt-rev-encourage-tooltip": "Restore this page to normal translation.",
+ "translate-edit-tag-warning": "",
"translate-tag-translate-link-desc": "Translate this page",
"translate-tag-markthis": "Mark this page for translation",
"translate-tag-markthisagain": "This page has <span
class=\"plainlinks\">[$1 changes]</span> since it was last <span
class=\"plainlinks\">[$2 marked for translation]</span>.",
diff --git a/i18n/pagetranslation/qqq.json b/i18n/pagetranslation/qqq.json
index 9e54a55..6743a66 100644
--- a/i18n/pagetranslation/qqq.json
+++ b/i18n/pagetranslation/qqq.json
@@ -69,6 +69,7 @@
"tpt-rev-unmark-tooltip": "Tooltip for page action link text in
[[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin
view]]",
"tpt-rev-discourage-tooltip": "Tooltip for page action link text in
[[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin
view]]",
"tpt-rev-encourage-tooltip": "Tooltip for page action link text in
[[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin
view]]",
+ "translate-edit-tag-warning": "{{notranslate}}\nShown when editing
translatable pages. Default is empty.",
"translate-tag-translate-link-desc": "Link at the top of translatable
pages, see [[mw:Help:Extension:Translate/Translation example]] for context.",
"translate-tag-markthis": "See definition on
[[mw:Help:Extension:Translate/Glossary]].",
"translate-tag-markthisagain": "\"has changes\" is to be understood as
\"has been altered/edited\".\n\nParameters:\n* $1 - a link which points to the
diff\n* $2 - a link which points to ...",
diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php
index ec30687..cbe371c 100644
--- a/tag/PageTranslationHooks.php
+++ b/tag/PageTranslationHooks.php
@@ -75,6 +75,22 @@
return true;
}
+ /**
+ * Display an edit notice for translatable source pages if it's enabled
+ * Hook: TitleGetEditNotices
+ *
+ * @param Title $title
+ * @param int $oldid
+ * @param array &$notices
+ */
+ public static function onTitleGetEditNotices( Title $title, $oldid,
array &$notices ) {
+ $msg = wfMessage( 'translate-edit-tag-warning'
)->inContentLanguage();
+
+ if ( !$msg->isDisabled() && TranslatablePage::isSourcePage(
$title ) ) {
+ $notices['translate-tag'] = $msg->parseAsBlock();
+ }
+ }
+
/// Hook: OutputPageBeforeHTML
public static function injectCss( OutputPage $out, /*string*/$text ) {
global $wgTranslatePageTranslationULS;
--
To view, visit https://gerrit.wikimedia.org/r/305959
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I455d7b6aee53073b78f4615e997e5cbf991c1a4a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
Gerrit-Reviewer: Glaisher <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits