21 public function __construct( ApiQuery $query,
string $moduleName ) {
22 parent::__construct( $query, $moduleName,
'mt' );
25 public function getCacheMode( $params ) {
29 public function execute():
void {
30 $params = $this->extractRequestParams();
32 $title = Title::newFromText( $params[
'title'] );
34 $this->dieWithError( [
'apierror-invalidtitle', wfEscapeWikiText( $params[
'title'] ) ] );
38 if ( !$handle->isValid() ) {
39 $this->dieWithError(
'apierror-translate-nomessagefortitle',
'nomessagefortitle' );
42 $namespace = $title->getNamespace();
43 $pageInfo = Utilities::getTranslations( $handle );
45 $result = $this->getResult();
48 foreach ( $pageInfo as $key => $info ) {
49 if ( ++$count <= $params[
'offset'] ) {
53 $tTitle = Title::makeTitle( $namespace, $key );
57 'title' => $tTitle->getPrefixedText(),
58 'language' => $tHandle->getCode(),
59 'lasttranslator' => $info[1],
65 $data[
'fuzzy'] =
'fuzzy';
68 $translation = str_replace( TRANSLATE_FUZZY,
'', $info[0] );
69 ApiResult::setContentValue( $data,
'translation', $translation );
71 $fit = $result->addValue( [
'query', $this->getModuleName() ],
null, $data );
73 $this->setContinueEnumParameter(
'offset', $count );
78 $result->addIndexedTagName( [
'query', $this->getModuleName() ],
'message' );
81 protected function getAllowedParams(): array {
84 ParamValidator::PARAM_TYPE =>
'string',
85 ParamValidator::PARAM_REQUIRED =>
true,
88 ParamValidator::PARAM_DEFAULT => 0,
89 ParamValidator::PARAM_TYPE =>
'integer',
90 ApiBase::PARAM_HELP_MSG =>
'api-help-param-continue',
95 protected function getExamplesMessages(): array {
97 'action=query&meta=messagetranslations&mttitle=MediaWiki:January'
98 =>
'apihelp-query+messagetranslations-example-1',