41 if ( $params[
'lang'] ===
null ) {
43 } elseif ( !$this->languageNameUtils->isValidCode( $params[
'lang'] ) ) {
45 [
'apierror-invalidlang', $this->
encodeParamName(
'lang' ) ],
'invalidlang'
48 $langObj = $this->languageFactory->getLanguage( $params[
'lang'] );
51 if ( $params[
'enableparser'] ) {
52 if ( $params[
'title'] !==
null ) {
53 $title = Title::newFromText( $params[
'title'] );
54 if ( !$title || $title->isExternal() ) {
58 $title = Title::newFromText(
'API' );
62 $prop = array_fill_keys( (array)$params[
'prop'],
true );
65 if ( in_array(
'*', $params[
'messages'] ) ) {
66 $message_names = $this->localisationCache->getSubitemList( $langObj->getCode(),
'messages' ) ?? [];
67 if ( $params[
'includelocal'] ) {
68 $message_names = array_unique( array_merge(
74 $this->messageCache->getAllMessageKeys( $this->contentLanguage->getCode() )
77 sort( $message_names );
78 $messages_target = $message_names;
80 $messages_target = $params[
'messages'];
85 if ( isset( $params[
'prefix'] ) ) {
87 $messages_filtered = [];
88 foreach ( $messages_target as $message ) {
89 if ( str_starts_with( $message, $params[
'prefix'] ) ) {
93 $messages_filtered[] = $message;
98 $messages_target = $messages_filtered;
102 if ( isset( $params[
'filter'] ) ) {
103 $messages_filtered = [];
104 foreach ( $messages_target as $message ) {
105 if ( str_contains( $message, $params[
'filter'] ) ) {
106 $messages_filtered[] = $message;
109 $messages_target = $messages_filtered;
113 $customiseFilterEnabled = $params[
'customised'] !==
'all';
114 if ( $customiseFilterEnabled ) {
117 $langObj->ucfirst( ... ),
121 !$langObj->equals( $this->contentLanguage ),
125 $customised = $params[
'customised'] ===
'modified';
129 $skip = $params[
'from'] !==
null;
130 $useto = $params[
'to'] !==
null;
132 foreach ( $messages_target as $message ) {
134 if ( $skip && $message === $params[
'from'] ) {
138 if ( $useto && $message > $params[
'to'] ) {
145 'normalizedname' => $this->messageCache->normalizeKey( $message ),
149 if ( isset( $params[
'args'] ) && count( $params[
'args'] ) != 0 ) {
150 $args = $params[
'args'];
153 if ( $customiseFilterEnabled ) {
154 $messageIsCustomised = isset( $customisedMessages[
'pages'][$langObj->ucfirst( $message )] );
156 if ( $customised === $messageIsCustomised ) {
159 $a[
'customised'] =
true;
166 $msg = $this->
msg( $message, $args )->inLanguage( $langObj );
168 if ( !$msg->exists() ) {
169 $a[
'missing'] =
true;
172 if ( $params[
'enableparser'] ) {
174 $msgString = $msg->page( $title )->text();
176 $msgString = $msg->plain();
178 if ( !$params[
'nocontent'] ) {
181 if ( isset( $prop[
'default'] ) ) {
182 $default = $this->
msg( $message )->inLanguage( $langObj )->useDatabase(
false );
183 if ( !$default->exists() ) {
184 $a[
'defaultmissing'] =
true;
185 } elseif ( $default->plain() != $msgString ) {
186 $a[
'default'] = $default->plain();
190 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $a );
197 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'message' );
218 ParamValidator::PARAM_DEFAULT =>
'*',
219 ParamValidator::PARAM_ISMULTI =>
true,
222 ParamValidator::PARAM_ISMULTI =>
true,
223 ParamValidator::PARAM_TYPE => [
227 'enableparser' =>
false,
228 'nocontent' =>
false,
229 'includelocal' =>
false,
231 ParamValidator::PARAM_ISMULTI =>
true,
232 ParamValidator::PARAM_ALLOW_DUPLICATES =>
true,
236 ParamValidator::PARAM_DEFAULT =>
'all',
237 ParamValidator::PARAM_TYPE => [