Page MenuHomePhabricator

Allow to hide translations on special page "WhatLinksHere"
Open, Needs TriagePublic

Description

Setup

  • MediaWiki 1.33.0-wmf.17 (rMW484a1d08a285) 21:23, 14 February 2019
  • Translate 2018-11-05 (9484763) 23:28, 11 February 2019

Issue
The number of links to translated pages may get overwhelming when using special page "WhatLinksHere". See this example. Thus it will be nice to have a filter "Show/Hide translations" with hide translations enabled be default.

Related Objects

Event Timeline

Kghbln created this task.Feb 17 2019, 5:57 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 17 2019, 5:57 PM
Kghbln updated the task description. (Show Details)Feb 17 2019, 5:58 PM
Nikerabbit added a subscriber: Nikerabbit.

There is one hook in Special:WhatLinksHere and that cannot be used to implement this feature in the Translate extension. Moving to "cross projects" column because I cannot set the priority.

There is one hook in Special:WhatLinksHere and that cannot be used to implement this feature in the Translate extension. Moving to "cross projects" column because I cannot set the priority.

Thanks for the note. Ultimately it will be good to be able to even select a specific language to be shown but I guess on step at a time is the best approach.

Okay, so, assuming hooks can be used to allow this, there needs to be a way to detect page translations via sql.
Currently, the logic for detecting them to prevent direct editing is:

PageTranslationHooks::preventDirectEditing
[...]
$page = TranslatablePage::isTranslationPage( $title );
if ( $page !== false && $page->getMarkedTag() ) {
	[...]
	return false;
}
return true;
TranslatablePage::isTranslationPage
public static function isTranslationPage( Title $title ) {
	$handle = new MessageHandle( $title );
	$key = $handle->getKey();
	$code = $handle->getCode();
	if ( $key === '' || $code === '' ) {
		return false;
	}
	$codes = Language::fetchLanguageNames();
	global $wgTranslateDocumentationLanguageCode;
	unset( $codes[$wgTranslateDocumentationLanguageCode] );
	if ( !isset( $codes[$code] ) ) {
		return false;
	}
	$newtitle = self::changeTitleText( $title, $key );
	if ( !$newtitle ) {
		return false;
	}
	$page = self::newFromTitle( $newtitle );
	if ( $page->getMarkedTag() === false ) {
		return false;
	}
	return $page;
}
MessageHandle::__construct
public function __construct( Title $title ) {
	$this->title = $title;
}

A bad way to try and add sql filtering would be to ensure that the page title doesn't end with a language code, but that would also exclude translations that are not a part of the translate system.

If it need to be done with SQL, perhaps setting a prop in page_props (or revtag) could make it fast and accurate enough?