39 if ( is_null( $params[
'lang'] ) ) {
41 } elseif ( !Language::isValidCode( $params[
'lang'] ) ) {
43 [
'apierror-invalidlang', $this->
encodeParamName(
'lang' ) ],
'invalidlang'
46 $langObj = Language::factory( $params[
'lang'] );
49 if ( $params[
'enableparser'] ) {
50 if ( !is_null( $params[
'title'] ) ) {
51 $title = Title::newFromText( $params[
'title'] );
56 $title = Title::newFromText(
'API' );
60 $prop = array_flip( (array)$params[
'prop'] );
63 if ( in_array(
'*', $params[
'messages'] ) ) {
64 $message_names = Language::getMessageKeysFor( $langObj->getCode() );
65 if ( $params[
'includelocal'] ) {
66 $message_names = array_unique( array_merge(
72 MessageCache::singleton()->getAllMessageKeys( $this->
getConfig()->
get(
'LanguageCode' ) )
75 sort( $message_names );
76 $messages_target = $message_names;
78 $messages_target = $params[
'messages'];
83 if ( isset( $params[
'prefix'] ) ) {
85 $messages_filtered = [];
86 foreach ( $messages_target as $message ) {
88 if ( strpos( $message, $params[
'prefix'] ) === 0 ) {
92 $messages_filtered[] = $message;
97 $messages_target = $messages_filtered;
101 if ( isset( $params[
'filter'] ) ) {
102 $messages_filtered = [];
103 foreach ( $messages_target as $message ) {
105 if ( strpos( $message, $params[
'filter'] ) !==
false ) {
106 $messages_filtered[] = $message;
109 $messages_target = $messages_filtered;
113 $customiseFilterEnabled = $params[
'customised'] !==
'all';
114 if ( $customiseFilterEnabled ) {
117 [ $langObj,
'ucfirst' ],
121 !$langObj->equals( MediaWikiServices::getInstance()->getContentLanguage() )
124 $customised = $params[
'customised'] ===
'modified';
128 $skip = !is_null( $params[
'from'] );
129 $useto = !is_null( $params[
'to'] );
131 foreach ( $messages_target as $message ) {
133 if ( $skip && $message === $params[
'from'] ) {
137 if ( $useto && $message > $params[
'to'] ) {
144 'normalizedname' => MessageCache::normalizeKey( $message ),
148 if ( isset( $params[
'args'] ) && count( $params[
'args'] ) != 0 ) {
149 $args = $params[
'args'];
152 if ( $customiseFilterEnabled ) {
153 $messageIsCustomised = isset( $customisedMessages[
'pages'][$langObj->ucfirst( $message )] );
154 if ( $customised === $messageIsCustomised ) {
156 $a[
'customised'] =
true;
165 if ( !$msg->exists() ) {
166 $a[
'missing'] =
true;
169 if ( $params[
'enableparser'] ) {
170 $msgString = $msg->title(
$title )->text();
172 $msgString = $msg->plain();
174 if ( !$params[
'nocontent'] ) {
175 ApiResult::setContentValue( $a,
'content', $msgString );
177 if ( isset( $prop[
'default'] ) ) {
178 $default =
wfMessage( $message )->inLanguage( $langObj )->useDatabase(
false );
179 if ( !$default->exists() ) {
180 $a[
'defaultmissing'] =
true;
181 } elseif ( $default->plain() != $msgString ) {
182 $a[
'default'] = $default->plain();
186 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $a );
193 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'message' );