66 Hooks::run(
'LocalisationIgnoredOptionalMessages',
67 [ &$this->mIgnoredMessages, &$this->mOptionalMessages ] );
70 sort( $this->mLanguages );
106 if ( isset( $this->mRawMessages[
$code] ) &&
107 isset( $this->mFallback[$code] ) &&
108 isset( $this->mNamespaceNames[$code] ) &&
109 isset( $this->mNamespaceAliases[$code] ) &&
110 isset( $this->mMagicWords[$code] ) &&
111 isset( $this->mSpecialPageAliases[$code] )
115 $this->mRawMessages[
$code] = [];
116 $this->mFallback[
$code] =
'';
117 $this->mNamespaceNames[
$code] = [];
118 $this->mNamespaceAliases[
$code] = [];
119 $this->mMagicWords[
$code] = [];
120 $this->mSpecialPageAliases[
$code] = [];
123 if ( file_exists( $jsonfilename ) ) {
125 $this->mRawMessages[
$code] = $json[
'messages'];
129 if ( file_exists( $filename ) ) {
164 if ( isset( $this->mMessages[
$code] ) ) {
169 $this->mMessages[
$code][
'all'] = $this->mRawMessages[
$code];
170 $this->mMessages[
$code][
'required'] = [];
171 $this->mMessages[
$code][
'optional'] = [];
172 $this->mMessages[
$code][
'obsolete'] = [];
173 $this->mMessages[
$code][
'translated'] = [];
174 foreach ( $this->mMessages[$code][
'all']
as $key =>
$value ) {
175 if ( isset( $this->mGeneralMessages[
'required'][$key] ) ) {
176 $this->mMessages[
$code][
'required'][$key] =
$value;
177 $this->mMessages[
$code][
'translated'][$key] =
$value;
178 } elseif ( isset( $this->mGeneralMessages[
'optional'][$key] ) ) {
179 $this->mMessages[
$code][
'optional'][$key] =
$value;
180 $this->mMessages[
$code][
'translated'][$key] =
$value;
182 $this->mMessages[
$code][
'obsolete'][$key] =
$value;
199 if ( isset( $this->mGeneralMessages ) ) {
203 $this->mGeneralMessages[
'all'] = $this->mRawMessages[
'en'];
204 $this->mGeneralMessages[
'required'] = [];
205 $this->mGeneralMessages[
'optional'] = [];
206 $this->mGeneralMessages[
'ignored'] = [];
207 $this->mGeneralMessages[
'translatable'] = [];
208 foreach ( $this->mGeneralMessages[
'all']
as $key =>
$value ) {
209 if ( in_array( $key, $this->mIgnoredMessages ) ) {
210 $this->mGeneralMessages[
'ignored'][$key] =
$value;
211 } elseif ( in_array( $key, $this->mOptionalMessages ) ) {
212 $this->mGeneralMessages[
'optional'][$key] =
$value;
213 $this->mGeneralMessages[
'translatable'][$key] =
$value;
215 $this->mGeneralMessages[
'required'][$key] =
$value;
216 $this->mGeneralMessages[
'translatable'][$key] =
$value;
240 return $this->mMessages[
$code];
272 return $this->mFallback[
$code];
285 return $this->mNamespaceNames[
$code];
298 return $this->mNamespaceAliases[
$code];
311 return $this->mMagicWords[
$code];
324 return $this->mSpecialPageAliases[
$code];
338 return array_diff_key( $this->mGeneralMessages[
'required'], $this->mMessages[
$code][
'required'] );
351 $duplicateMessages = [];
352 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
353 if ( $this->mGeneralMessages[
'translatable'][$key] ==
$value ) {
354 $duplicateMessages[$key] =
$value;
358 return $duplicateMessages;
372 return $this->mMessages[
$code][
'obsolete'];
385 $variables = [
'\$1',
'\$2',
'\$3',
'\$4',
'\$5',
'\$6',
'\$7',
'\$8',
'\$9' ];
386 $mismatchMessages = [];
387 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
389 foreach ( $variables
as $var ) {
390 if ( preg_match(
"/$var/sU", $this->mGeneralMessages[
'translatable'][$key] ) &&
391 !preg_match(
"/$var/sU",
$value )
395 if ( !preg_match(
"/$var/sU", $this->mGeneralMessages[
'translatable'][$key] ) &&
396 preg_match(
"/$var/sU",
$value )
402 $mismatchMessages[$key] =
$value;
406 return $mismatchMessages;
419 $messagesWithoutPlural = [];
420 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
421 if ( stripos( $this->mGeneralMessages[
'translatable'][$key],
'{{plural:' ) !==
false &&
422 stripos(
$value,
'{{plural:' ) ===
false
424 $messagesWithoutPlural[$key] =
$value;
428 return $messagesWithoutPlural;
442 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
444 $emptyMessages[$key] =
$value;
448 return $emptyMessages;
461 $messagesWithWhitespace = [];
462 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
463 if ( $this->mGeneralMessages[
'translatable'][$key] !==
'' &&
$value !== rtrim(
$value ) ) {
464 $messagesWithWhitespace[$key] =
$value;
468 return $messagesWithWhitespace;
489 $wrongPhrases =
'~(' . implode(
'|', $wrongPhrases ) .
')~sDu';
490 $nonXHTMLMessages = [];
491 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
492 if ( preg_match( $wrongPhrases,
$value ) ) {
493 $nonXHTMLMessages[$key] =
$value;
497 return $nonXHTMLMessages;
511 '[LRM]' =>
"\xE2\x80\x8E",
512 '[RLM]' =>
"\xE2\x80\x8F",
513 '[LRE]' =>
"\xE2\x80\xAA",
514 '[RLE]' =>
"\xE2\x80\xAB",
515 '[POP]' =>
"\xE2\x80\xAC",
516 '[LRO]' =>
"\xE2\x80\xAD",
517 '[RLO]' =>
"\xE2\x80\xAB",
518 '[ZWSP]' =>
"\xE2\x80\x8B",
519 '[NBSP]' =>
"\xC2\xA0",
520 '[WJ]' =>
"\xE2\x81\xA0",
521 '[BOM]' =>
"\xEF\xBB\xBF",
522 '[FFFD]' =>
"\xEF\xBF\xBD",
524 $wrongRegExp =
'/(' . implode(
'|', array_values( $wrongChars ) ) .
')/sDu';
525 $wrongCharsMessages = [];
526 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
527 if ( preg_match( $wrongRegExp,
$value ) ) {
528 foreach ( $wrongChars
as $viewableChar => $hiddenChar ) {
529 $value = str_replace( $hiddenChar, $viewableChar,
$value );
531 $wrongCharsMessages[$key] =
$value;
535 return $wrongCharsMessages;
550 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
552 preg_match_all(
"/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu",
$value,
$matches );
554 for ( $i = 0; $i < $numMatches; $i++ ) {
555 if ( preg_match(
"/.*project.*/isDu",
$matches[1][$i] ) ) {
579 foreach ( $this->mMessages[
$code][
'translated']
as $key =>
$value ) {
580 $a = $b = $c = $d = 0;
581 foreach ( preg_split(
'//',
$value )
as $char ) {
598 if ( $a !== $b || $c !== $d ) {
616 $namespacesDiff = array_diff_key( $this->mNamespaceNames[
'en'], $this->mNamespaceNames[
$code] );
617 if ( isset( $namespacesDiff[
NS_MAIN] ) ) {
618 unset( $namespacesDiff[NS_MAIN] );
621 return $namespacesDiff;
635 # Check default namespace name
638 if ( strpos( $default,
'$1' ) ===
false ) {
643 # Check namespace aliases
644 foreach ( $this->mNamespaceAliases[
$code]
as $key =>
$value ) {
645 if (
$value == NS_PROJECT_TALK && strpos( $key,
'$1' ) ===
false ) {
664 foreach ( $this->mMagicWords[
'en']
as $key =>
$value ) {
665 if ( !isset( $this->mMagicWords[
$code][$key] ) ) {
685 if ( !isset( $this->mMagicWords[
'en'][$key] ) ) {
704 foreach ( $this->mMagicWords[
$code]
as $key => $local ) {
705 if ( !isset( $this->mMagicWords[
'en'][$key] ) ) {
706 # Unrecognized magic word
709 $en = $this->mMagicWords[
'en'][$key];
710 array_shift( $local );
712 foreach ( $en
as $word ) {
713 if ( !in_array( $word, $local ) ) {
734 foreach ( $this->mMagicWords[
$code]
as $key => $local ) {
735 if ( !isset( $this->mMagicWords[
'en'][$key] ) ) {
736 # Unrecognized magic word
739 if ( $local[0] != $this->mMagicWords[
'en'][$key][0] ) {
758 foreach ( $this->mSpecialPageAliases[
'en']
as $key =>
$value ) {
759 if ( !isset( $this->mSpecialPageAliases[
$code][$key] ) ) {
778 foreach ( $this->mSpecialPageAliases[
$code]
as $key =>
$value ) {
779 if ( !isset( $this->mSpecialPageAliases[
'en'][$key] ) ) {
799 $this->mMessageGroup = $group;
801 $this->mIgnoredMessages = $this->mMessageGroup->getIgnored();
802 $this->mOptionalMessages = $this->mMessageGroup->getOptional();
811 return $this->mMessageGroup->getLabel();
820 if ( !isset( $this->mRawMessages[
$code] ) ) {
821 $this->mRawMessages[
$code] = $this->mMessageGroup->load( $code );
822 if ( empty( $this->mRawMessages[$code] ) ) {
823 $this->mRawMessages[
$code] = [];
static getLocalisationCache()
Get the LocalisationCache instance.
array $mFallback
Fallback language in each language.
__construct(MessageGroup $group)
Load the messages group.
array $mNamespaceAliases
Namespace aliases.
array $mRawMessages
Raw list of the messages in each language.
getUntranslatedNamespaces($code)
Get the untranslated namespace names.
getUntranslatedMagicWords($code)
Get the untranslated magic words.
getEmptyMessages($code)
Get the empty messages.
array $mOptionalMessages
All the messages which may be translated or not, depending on the language.
getGeneralMessages()
Get all the general English messages, divided to groups: all - all the messages.
getObsoleteMagicWords($code)
Get the obsolete magic words.
getFallback($code)
Get fallback language code for a specific language.
loadFile($code)
Load the language file.
getLanguages()
Get the language list.
array $mSpecialPageAliases
Special page aliases.
getIgnoredMessages()
Get the ignored messages list.
getMessagesWithUnbalanced($code)
Get the messages which include unbalanced brackets.
static fetchLanguageNames($inLanguage=null, $include= 'mw')
Get an array of language names, indexed by code.
static getJsonMessagesFileName($code)
getUntranslatedMessages($code)
Get the untranslated messages for a specific language.
getOptionalMessages()
Get the optional messages list.
getMessagesWithWrongChars($code)
Get the messages which include wrong characters.
__construct()
Load the list of languages: all the Messages*.php files in the languages directory.
getNamespaceNames($code)
Get namespace names for a specific language.
getMessagesWithMismatchVariables($code)
Get the messages whose variables do not match the original ones.
getObsoleteSpecialPages($code)
Get the obsolete special page names.
getSpecialPageAliases($code)
Get special page aliases for a specific language.
MessageGroup $mMessageGroup
array $mMessages
Messages in each language (except for English), divided to groups.
loadFile($code)
Load the language file.
static getMessagesFileName($code)
getMagicWords($code)
Get magic words for a specific language.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
namespace and then decline to actually register it & $namespaces
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
getMessagesWithWhitespace($code)
Get the messages with trailing whitespace.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
array $mIgnoredMessages
All the messages which should be exist only in the English file.
array $mGeneralMessages
General messages in English, divided to groups.
getMessages($code)
Get all the messages for a specific language (not English), without the fallback language messages...
static legalChars()
Get a regex character class describing the legal characters in a link.
name()
Get the extension name.
getOverridingMagicWords($code)
Get the magic words that override the original English magic word.
array $mLanguages
List of languages.
getUntraslatedSpecialPages($code)
Get the untranslated special page names.
loadMessages($code)
Load the messages for a specific language (which is not English) and divide them to groups: all - all...
getMessagesWithDubiousLinks($code)
Get the messages which include dubious links.
getCaseMismatchMagicWords($code)
Get the magic words which do not match the case-sensitivity of the original words.
getProblematicProjectTalks($code)
Get the project talk namespace names with no $1.
getNamespaceAliases($code)
Get namespace aliases for a specific language.
getMessagesWithoutPlural($code)
Get the messages which do not use plural.
getObsoleteMessages($code)
Get the obsolete messages for a specific language.
getNonXHTMLMessages($code)
Get the non-XHTML messages.
array $mNamespaceNames
Namespace names.
getDuplicateMessages($code)
Get the duplicate messages for a specific language.
array $mMagicWords
Magic words.
loadGeneralMessages()
Load the messages for English and divide them to groups: all - all the messages.
magicword txt Magic Words are some phrases used in the wikitext They are used for two that looks like templates but that don t accept any parameter *Parser functions(like{{fullurl:...}},{{#special:...}}) $magicWords['en']