summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/specials/SpecialTranslate.php')
-rw-r--r--MLEB/Translate/specials/SpecialTranslate.php56
1 files changed, 19 insertions, 37 deletions
diff --git a/MLEB/Translate/specials/SpecialTranslate.php b/MLEB/Translate/specials/SpecialTranslate.php
index 305c1e00..d7e7d6bd 100644
--- a/MLEB/Translate/specials/SpecialTranslate.php
+++ b/MLEB/Translate/specials/SpecialTranslate.php
@@ -8,6 +8,8 @@
* @license GPL-2.0-or-later
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Implements the core of Translate extension - a special page which shows
* a list of messages in a format defined by Tasks.
@@ -31,7 +33,7 @@ class SpecialTranslate extends SpecialPage {
}
protected function getGroupName() {
- return 'wiki';
+ return 'translation';
}
/**
@@ -50,16 +52,14 @@ class SpecialTranslate extends SpecialPage {
$this->setHeaders();
- $request = $this->getRequest();
+ $this->setup( $parameters );
- if ( !defined( 'ULS_VERSION' ) ) {
- throw new ErrorPageError(
- 'translate-ulsdep-title',
- 'translate-ulsdep-body'
- );
+ // Redirect old export URLs to Special:ExportTranslations
+ if ( $this->getRequest()->getText( 'taction' ) === 'export' ) {
+ $exportPage = SpecialPage::getTitleFor( 'ExportTranslations' );
+ $out->redirect( $exportPage->getLocalURL( $this->nondefaults ) );
}
- $this->setup( $parameters );
$out->addModules( 'ext.translate.special.translate' );
$out->addJsConfigVars( 'wgTranslateLanguages', TranslateUtils::getLanguageNames( null ) );
@@ -81,7 +81,6 @@ class SpecialTranslate extends SpecialPage {
$request = $this->getRequest();
$defaults = [
- /* str */'taction' => 'translate',
/* str */'language' => $this->getLanguage()->getCode(),
/* str */'group' => '!additions',
];
@@ -126,23 +125,6 @@ class SpecialTranslate extends SpecialPage {
wfAppendToArrayIfNotDefault( $v, $r, $defaults, $nondefaults );
}
- // Fix defaults based on what we got
- if ( isset( $nondefaults['taction'] ) ) {
- if ( $nondefaults['taction'] === 'export' ) {
- // Redirect old export URLs to Special:ExportTranslations
- $params = [];
- if ( isset( $nondefaults['group'] ) ) {
- $params['group'] = $nondefaults['group'];
- }
- if ( isset( $nondefaults['language'] ) ) {
- $params['language'] = $nondefaults['language'];
- }
-
- $export = SpecialPage::getTitleFor( 'ExportTranslations' )->getLocalURL( $params );
- $this->getOutput()->redirect( $export );
- }
- }
-
$this->defaults = $defaults;
$this->nondefaults = $nondefaults;
Hooks::run( 'TranslateGetSpecialTranslateOptions', [ &$defaults, &$nondefaults ] );
@@ -155,7 +137,12 @@ class SpecialTranslate extends SpecialPage {
$this->group = MessageGroups::getGroup( $this->defaults['group'] );
}
+ if ( !Language::isKnownLanguageTag( $this->options['language'] ) ) {
+ $this->options['language'] = $this->defaults['language'];
+ }
+
if ( MessageGroups::isDynamic( $this->group ) ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$this->group->setLanguage( $this->options['language'] );
}
}
@@ -217,7 +204,7 @@ class SpecialTranslate extends SpecialPage {
// and and also for the data-filter attribute.
// The message is shown as the check box's label.
$options = [
- 'optional' => $this->msg( 'tux-message-filter-optional-messages-label' )->escaped(),
+ 'optional' => $this->msg( 'tux-message-filter-optional-messages-label' )->text(),
];
$container = Html::openElement( 'ul', [ 'class' => 'column tux-message-selector' ] );
@@ -328,12 +315,8 @@ class SpecialTranslate extends SpecialPage {
protected function getGroupDescription( MessageGroup $group ) {
$description = $group->getDescription( $this->getContext() );
- if ( $description !== null ) {
- return TranslateUtils::parseAsInterface(
- $this->getOutput(), $description
- );
- }
- return '';
+ return $description === null ?
+ '' : $this->getOutput()->parseAsInterface( $description );
}
protected function tuxGroupWarning() {
@@ -367,7 +350,8 @@ class SpecialTranslate extends SpecialPage {
*/
public static function tabify( Skin $skin, array &$tabs ) {
$title = $skin->getTitle();
- list( $alias, $sub ) = TranslateUtils::resolveSpecialPageAlias( $title->getText() );
+ list( $alias, $sub ) = MediaWikiServices::getInstance()
+ ->getSpecialPageFactory()->resolveAlias( $title->getText() );
$pagesInGroup = [ 'Translate', 'LanguageStats', 'MessageGroupStats' ];
if ( !in_array( $alias, $pagesInGroup, true ) ) {
@@ -392,8 +376,6 @@ class SpecialTranslate extends SpecialPage {
$params['language'] = $request->getVal( 'language' );
$params['group'] = $request->getVal( 'group' );
- $taction = $request->getVal( 'taction', 'translate' );
-
$translate = SpecialPage::getTitleFor( 'Translate' );
$languagestats = SpecialPage::getTitleFor( 'LanguageStats' );
$messagegroupstats = SpecialPage::getTitleFor( 'MessageGroupStats' );
@@ -407,7 +389,7 @@ class SpecialTranslate extends SpecialPage {
'class' => 'tux-tab',
];
- if ( $alias === 'Translate' && $taction === 'translate' ) {
+ if ( $alias === 'Translate' ) {
$tabs['namespaces']['translate']['class'] .= ' selected';
}