54 Language $contentLanguage,
60 parent::__construct( $query, $moduleName,
'am' );
61 $this->contentLanguage = $contentLanguage;
62 $this->languageFactory = $languageFactory;
63 $this->languageNameUtils = $languageNameUtils;
64 $this->localisationCache = $localisationCache;
65 $this->messageCache = $messageCache;
70 if (
$params[
'lang'] ===
null ) {
72 } elseif ( !$this->languageNameUtils->isValidCode(
$params[
'lang'] ) ) {
74 [
'apierror-invalidlang', $this->
encodeParamName(
'lang' ) ],
'invalidlang'
77 $langObj = $this->languageFactory->getLanguage(
$params[
'lang'] );
80 if (
$params[
'enableparser'] ) {
81 if (
$params[
'title'] !==
null ) {
82 $title = Title::newFromText(
$params[
'title'] );
83 if ( !$title || $title->isExternal() ) {
87 $title = Title::newFromText(
'API' );
91 $prop = array_fill_keys( (array)
$params[
'prop'],
true );
94 if ( in_array(
'*',
$params[
'messages'] ) ) {
95 $message_names = $this->localisationCache->getSubitemList( $langObj->getCode(),
'messages' ) ?? [];
96 if (
$params[
'includelocal'] ) {
97 $message_names = array_unique( array_merge(
103 $this->messageCache->getAllMessageKeys( $this->contentLanguage->getCode() )
106 sort( $message_names );
107 $messages_target = $message_names;
109 $messages_target =
$params[
'messages'];
114 if ( isset(
$params[
'prefix'] ) ) {
116 $messages_filtered = [];
117 foreach ( $messages_target as $message ) {
118 if ( str_starts_with( $message,
$params[
'prefix'] ) ) {
122 $messages_filtered[] = $message;
127 $messages_target = $messages_filtered;
131 if ( isset(
$params[
'filter'] ) ) {
132 $messages_filtered = [];
133 foreach ( $messages_target as $message ) {
134 if ( str_contains( $message,
$params[
'filter'] ) ) {
135 $messages_filtered[] = $message;
138 $messages_target = $messages_filtered;
142 $customiseFilterEnabled =
$params[
'customised'] !==
'all';
143 if ( $customiseFilterEnabled ) {
144 $customisedMessages = AllMessagesTablePager::getCustomisedStatuses(
146 [ $langObj,
'ucfirst' ],
150 !$langObj->equals( $this->contentLanguage ),
154 $customised =
$params[
'customised'] ===
'modified';
158 $skip =
$params[
'from'] !==
null;
159 $useto =
$params[
'to'] !==
null;
161 foreach ( $messages_target as $message ) {
163 if ( $skip && $message ===
$params[
'from'] ) {
167 if ( $useto && $message >
$params[
'to'] ) {
174 'normalizedname' => MessageCache::normalizeKey( $message ),
178 if ( isset(
$params[
'args'] ) && count(
$params[
'args'] ) != 0 ) {
182 if ( $customiseFilterEnabled ) {
183 $messageIsCustomised = isset( $customisedMessages[
'pages'][$langObj->ucfirst( $message )] );
185 if ( $customised === $messageIsCustomised ) {
188 $a[
'customised'] =
true;
195 $msg = $this->
msg( $message, $args )->inLanguage( $langObj );
197 if ( !$msg->exists() ) {
198 $a[
'missing'] =
true;
201 if (
$params[
'enableparser'] ) {
203 $msgString = $msg->page( $title )->text();
205 $msgString = $msg->plain();
208 ApiResult::setContentValue( $a,
'content', $msgString );
210 if ( isset( $prop[
'default'] ) ) {
211 $default = $this->
msg( $message )->inLanguage( $langObj )->useDatabase(
false );
212 if ( !$default->exists() ) {
213 $a[
'defaultmissing'] =
true;
214 } elseif ( $default->plain() != $msgString ) {
215 $a[
'default'] = $default->plain();
219 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $a );
226 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'message' );
245 ParamValidator::PARAM_DEFAULT =>
'*',
246 ParamValidator::PARAM_ISMULTI =>
true,
249 ParamValidator::PARAM_ISMULTI =>
true,
250 ParamValidator::PARAM_TYPE => [
254 'enableparser' =>
false,
255 'nocontent' =>
false,
256 'includelocal' =>
false,
258 ParamValidator::PARAM_ISMULTI =>
true,
259 ParamValidator::PARAM_ALLOW_DUPLICATES =>
true,
263 ParamValidator::PARAM_DEFAULT =>
'all',
264 ParamValidator::PARAM_TYPE => [