Page MenuHomePhabricator

Localization of custom editintro messages
Open, LowPublicFeature

Description

Author: lhridley

Description:
Change showCustomIntro() to allow for localization of custom editintro messages

Custom editintro messages can be implemented by passing an additional parameter in the URL, "editintro=". Currently the value passed is the name of an article page on the wiki.

This does not allow for the localization of custom editintro messages without changing the url parameters for each and every language, an arduous task if you're building a custom editintro message into an extension.

The editintro functionality, which is contained in EditPage::showCustomIntro() can be easily modified to allow for an easier implementation of a localized custom editintro message. Then, such messages can be passed in an extension's .i18n. file and will be displayed based on the user's selected language.

A proposed solution would be to make the following change to EditPage::showCustomIntro() (patch is attached with this change)

/**

  • Attempt to show a custom editing introduction, if supplied *
  • Custom editing instructions can either be a message in the MediaWiki namespace, or an article page on the wiki
  • This function tests first to see if a message exists with the key passed as the "editintro" url parameter and
  • returns that message; if not, then it checks to see if an article exists on the wiki and returns the article contents
  • If neither exist, then returns false. *
  • @return bool
	 */

protected function showCustomIntro() {

		global $wgOut;
		if ( $this->editintro ) {
			# checks to see if there is an existing message in the message cache; if so, returns it.
			if( !wfEmptyMsg( wfMsg($this->editintro), $this->editintro ) ) {
				$wgOut->wrapWikiMsg( '<div class="mw-newarticlecustomtext">$1</div>', $this->editintro );
				return true;
			}
			$title = Title::newFromText( $this->editintro );
			if ( $title instanceof Title && $title->exists() && $title->userCanRead() ) {
				$revision = Revision::newFromTitle( $title );
				$wgOut->addWikiTextTitleTidy( $revision->getText(), $this->mTitle );
				return true;
			}
		} else {
			return false;
		}

}


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz22724

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:59 PM
bzimport set Reference to bz22724.
bzimport added a subscriber: Unknown Object (MLST).

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

Lisa Ridley, I'm sorry that no one responded to your patch for more than a year! I'm adding the "need-review" keyword now to signal to developers that your patch awaits review. Thanks for the contribution.

neilk wrote:

Another approach -- use MediaWiki: and internationalize everything

Attached:

neilk wrote:

Conferred with others, seems like a bit of a hack. Tried another way to do this (see attachment 9617) which was rejected as an even worse hack.

It is not obvious that this is high priority. Revising to low priority.

To the OP: since you are doing this with an extension, can you solve your problem with the EditPage::showEditForm:initial hook?

http://www.mediawiki.org/wiki/Manual:Hooks/EditPage::showEditForm:initial?

The patch is functionally OK. I don't see how it is a bad hack.

It is, however, very local: Reviewing it made me realize that currently the editintro system is, in general, used in a very strange way. Unless i'm missing something, in the core it can only be used naturally for a custom intro when adding talk page sections. For everything else really weird hacks are needed; for an example see function addEditIntro in https://en.wikipedia.org/wiki/MediaWiki:Common.js.

What would be really useful is to redo the editintro system so it would be useful without weird hacks.

For this particular issue using a hook, as Neil suggests, would probably be better.

sumanah wrote:

Marking patch reviewed; thanks, Amir.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.