22 public function __construct( ApiQuery $query,
string $moduleName ) {
23 parent::__construct( $query, $moduleName,
'mt' );
26 public function getCacheMode( $params ) {
30 public function execute():
void {
31 $params = $this->extractRequestParams();
33 $title = Title::newFromText( $params[
'title'] );
35 $this->dieWithError( [
'apierror-invalidtitle', wfEscapeWikiText( $params[
'title'] ) ] );
39 if ( !$handle->isValid() ) {
40 $this->dieWithError(
'apierror-translate-nomessagefortitle',
'nomessagefortitle' );
43 $namespace = $title->getNamespace();
44 $pageInfo = TranslateUtils::getTranslations( $handle );
46 $result = $this->getResult();
49 foreach ( $pageInfo as $key => $info ) {
50 if ( ++$count <= $params[
'offset'] ) {
54 $tTitle = Title::makeTitle( $namespace, $key );
58 'title' => $tTitle->getPrefixedText(),
59 'language' => $tHandle->getCode(),
60 'lasttranslator' => $info[1],
63 $fuzzy = MessageHandle::hasFuzzyString( $info[0] ) || $tHandle->isFuzzy();
66 $data[
'fuzzy'] =
'fuzzy';
69 $translation = str_replace( TRANSLATE_FUZZY,
'', $info[0] );
70 ApiResult::setContentValue( $data,
'translation', $translation );
72 $fit = $result->addValue( [
'query', $this->getModuleName() ],
null, $data );
74 $this->setContinueEnumParameter(
'offset', $count );
79 $result->addIndexedTagName( [
'query', $this->getModuleName() ],
'message' );
82 protected function getAllowedParams(): array {
85 ParamValidator::PARAM_TYPE =>
'string',
86 ParamValidator::PARAM_REQUIRED =>
true,
89 ParamValidator::PARAM_DEFAULT => 0,
90 ParamValidator::PARAM_TYPE =>
'integer',
91 ApiBase::PARAM_HELP_MSG =>
'api-help-param-continue',
96 protected function getExamplesMessages(): array {
98 'action=query&meta=messagetranslations&mttitle=MediaWiki:January'
99 =>
'apihelp-query+messagetranslations-example-1',