24 public function execute() {
25 $params = $this->extractRequestParams();
27 $title = Title::newFromText( $params[
'title'] );
29 $this->dieWithError( [
'apierror-invalidtitle', wfEscapeWikiText( $params[
'title'] ) ] );
33 if ( !$handle->isValid() ) {
34 $this->dieWithError(
'apierror-translate-nomessagefortitle',
'nomessagefortitle' );
37 if ( (
string)$params[
'group'] !==
'' ) {
38 $group = MessageGroups::getGroup( $params[
'group'] );
40 $group = $handle->getGroup();
44 $this->dieWithError(
'apierror-translate-invalidgroup',
'invalidgroup' );
50 $props = $params[
'prop'];
55 $props = array_intersect( $props, array_keys( $types ) );
57 $result = $this->getResult();
68 if ( !$dataProvider->hasDefinition() ) {
70 'Message definition is empty! Title: {title}, group: {group}, key: {key}',
72 'title' => $handle->getTitle()->getPrefixedText(),
73 'group' => $group->getId(),
74 'key' => $handle->getKey()
79 foreach ( $props as $type ) {
81 if ( !isset( $types[$type] ) ) {
82 $types[$type] = UnsupportedTranslationAid::class;
85 $class = $types[$type];
86 $obj =
new $class( $group, $handle, $this, $dataProvider );
89 $obj->setQueryAggregator( $aggregator );
91 $obj->populateQueries();
93 $data[$type] = [
'error' => $e->getMessage() ];
103 $start = microtime(
true );
105 $times[
'query_aggregator'] = round( microtime(
true ) - $start, 3 );
108 foreach ( $aids as $type => $obj ) {
109 $start = microtime(
true );
112 $aid = $obj->getData();
114 $aid = [
'error' => $e->getMessage() ];
117 if ( isset( $aid[
'**'] ) ) {
118 $result->setIndexedTagName( $aid, $aid[
'**'] );
123 $times[$type] = round( microtime(
true ) - $start, 3 );
126 $result->addValue(
null,
'helpers', $data );
127 $result->addValue(
null,
'times', $times );
130 protected function getAllowedParams(): array {
135 ParamValidator::PARAM_TYPE =>
'string',
136 ParamValidator::PARAM_REQUIRED =>
true,
139 ParamValidator::PARAM_TYPE =>
'string',
142 ParamValidator::PARAM_DEFAULT => implode(
'|', $props ),
143 ParamValidator::PARAM_TYPE => $props,
144 ParamValidator::PARAM_ISMULTI =>
true,
149 protected function getExamplesMessages() {
151 'action=translationaids&title=MediaWiki:January/fi'
152 =>
'apihelp-translationaids-example-1',