blob: 89f25f8acd78a0d42dce8b3faad748ec1f120aef (
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
|
<?php
/**
* Api module for language group stats.
*
* @file
* @author Niklas Laxström
* @license GPL-2.0-or-later
*/
/**
* Api module for querying language stats.
*
* @ingroup API TranslateAPI
* @since 2012-11-30
*/
class ApiQueryLanguageStats extends ApiStatsQuery {
public function __construct( $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'ls' );
}
// ApiStatsQuery methods
/** @inheritDoc */
protected function validateTargetParamater( array $params ) {
$requested = $params[ 'language' ];
if ( !TranslateUtils::isSupportedLanguageCode( $requested ) ) {
$this->dieWithError( [ 'apierror-translate-invalidlanguage', $requested ] );
}
return $requested;
}
/** @inheritDoc */
protected function loadStatistics( $target, $flags = 0 ) {
return MessageGroupStats::forLanguage( $target, $flags );
}
/** @inheritDoc */
protected function makeItem( $item, $stats ) {
$data = parent::makeItem( $item, $stats );
$data['group'] = $item;
return $data;
}
/** @inheritDoc */
protected function getCacheRebuildJob( string $target ): IJobSpecification {
return MessageGroupStatsRebuildJob::newJob( [ 'languagecode' => $target ] );
}
// Api methods
/** @inheritDoc */
protected function getAllowedParams() {
$params = parent::getAllowedParams();
$params['language'] = [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true,
];
return $params;
}
/** @inheritDoc */
protected function getExamplesMessages() {
return [
'action=query&meta=languagestats&lslanguage=fi'
=> 'apihelp-query+languagestats-example-1',
];
}
}
|