blob: 9503f3ab1bd0327fc7111506f7fac5e35a776a7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
<?php
/**
* Classes for adding extension specific toolbox menu items.
*
* @file
* @author Siebrand Mazeland
* @author Niklas Laxström
* @copyright Copyright © 2008-2010, Siebrand Mazeland, Niklas Laxström
* @license GPL-2.0-or-later
*/
/**
* Adds toolbox menu item to Special:Prefixindex to show all other
* available translations for a message. Only shown when it
* actually is a translatable/translated message.
*/
class TranslateToolbox {
/**
* This handler will be called for MW < 1.35
*
* @param BaseTemplate $baseTemplate The base skin template
* @param array &$toolbox An array of toolbox items
*
* @return void
*/
public static function toolboxAllTranslationsOld(
BaseTemplate $baseTemplate, array &$toolbox
): void {
$skin = $baseTemplate->getSkin();
$title = $skin->getTitle();
$handle = new MessageHandle( $title );
if ( !$handle->isValid() ) {
return;
}
$message = $title->getNsText() . ':' . $handle->getKey();
$url = $skin::makeSpecialUrl( 'Translations', [ 'message' => $message ] );
// Add the actual toolbox entry.
$toolbox[ 'alltrans' ] = [
'href' => $url,
'id' => 't-alltrans',
'msg' => 'translate-sidebar-alltrans',
];
}
/**
* This handler will be called for MW >= 1.35
*
* @param Skin $skin
* @param array &$sidebar Array with sidebar items
*
* @return void
*/
public static function toolboxAllTranslations( Skin $skin, array &$sidebar ): void {
$title = $skin->getTitle();
$handle = new MessageHandle( $title );
if ( !$handle->isValid() ) {
return;
}
$message = $title->getNsText() . ':' . $handle->getKey();
$url = $skin::makeSpecialUrl( 'Translations', [ 'message' => $message ] );
// Add the actual toolbox entry.
$sidebar['TOOLBOX'][ 'alltrans' ] = [
'href' => $url,
'id' => 't-alltrans',
'msg' => 'translate-sidebar-alltrans',
];
}
}
|