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
75
76
77
78
79
|
<?php
/**
* This file contains an unmanaged message group implementation.
*
* @file
* @author Niklas Laxström
* @author Siebrand Mazeland
* @copyright Copyright © 2008-2013, Niklas Laxström, Siebrand Mazeland
* @license GPL-2.0-or-later
*/
use MediaWiki\Extensions\Translate\SystemUsers\FuzzyBot;
/**
* @ingroup MessageGroup
*/
class WorkflowStatesMessageGroup extends WikiMessageGroup {
// id and source are not needed
public function __construct() {
}
public function getId() {
return 'translate-workflow-states';
}
public function getLabel( IContextSource $context = null ) {
$msg = wfMessage( 'translate-workflowgroup-label' );
$msg = self::addContext( $msg, $context );
return $msg->plain();
}
public function getDescription( IContextSource $context = null ) {
$msg = wfMessage( 'translate-workflowgroup-desc' );
$msg = self::addContext( $msg, $context );
return $msg->plain();
}
public function getDefinitions() {
$groups = MessageGroups::getAllGroups();
$keys = [];
/**
* @var $g MessageGroup
*/
foreach ( $groups as $g ) {
$states = $g->getMessageGroupStates()->getStates();
foreach ( array_keys( $states ) as $state ) {
$keys["Translate-workflow-state-$state"] = $state;
}
}
$defs = TranslateUtils::getContents( array_keys( $keys ), $this->getNamespace() );
foreach ( $keys as $key => $state ) {
if ( !isset( $defs[$key] ) ) {
// @todo Use jobqueue
$title = Title::makeTitleSafe( $this->getNamespace(), $key );
$page = new WikiPage( $title );
$content = ContentHandler::makeContent( $state, $title );
$page->doEditContent(
$content,
wfMessage( 'translate-workflow-autocreated-summary', $state )->inContentLanguage()->text(),
0, /*flags*/
false, /* base revision id */
FuzzyBot::getUser()
);
} else {
// Use the wiki translation as definition if available.
// getContents returns array( content, last author )
[ $content, ] = $defs[$key];
$keys[$key] = $content;
}
}
return $keys;
}
}
|