/**
* @ingroup MaintenanceLanguage
*/
-class languages {
- protected $mLanguages; # List of languages
+class Languages {
+ /** @var array List of languages */
+ protected $mLanguages; #
- protected $mRawMessages; # Raw list of the messages in each language
- protected $mMessages; # Messages in each language (except for English), divided to groups
- protected $mFallback; # Fallback language in each language
- protected $mGeneralMessages; # General messages in English, divided to groups
- protected $mIgnoredMessages; # All the messages which should be exist only in the English file
- protected $mOptionalMessages; # All the messages which may be translated or not, depending on the language
+ /** @var array Raw list of the messages in each language */
+ protected $mRawMessages;
- protected $mNamespaceNames; # Namespace names
- protected $mNamespaceAliases; # Namespace aliases
- protected $mMagicWords; # Magic words
- protected $mSpecialPageAliases; # Special page aliases
+ /** @var array Messages in each language (except for English), divided to groups */
+ protected $mMessages;
+
+ /** @var array Fallback language in each language */
+ protected $mFallback;
+
+ /** @var array General messages in English, divided to groups */
+ protected $mGeneralMessages;
+
+ /** @var array All the messages which should be exist only in the English file */
+ protected $mIgnoredMessages;
+
+ /** @var array All the messages which may be translated or not, depending on the language */
+ protected $mOptionalMessages;
+
+ /** @var array Namespace names */
+ protected $mNamespaceNames;
+
+ /** @var array Namespace aliases */
+ protected $mNamespaceAliases;
+
+ /** @var array Magic words */
+ protected $mMagicWords;
+
+ /** @var array Special page aliases */
+ protected $mSpecialPageAliases;
/**
* Load the list of languages: all the Messages*.php
* @param $exif bool Treat the Exif messages?
*/
function __construct( $exif = true ) {
- require( __DIR__ . '/messageTypes.inc' );
+ require __DIR__ . '/messageTypes.inc';
$this->mIgnoredMessages = $wgIgnoredMessages;
if ( $exif ) {
$this->mOptionalMessages = array_merge( $wgOptionalMessages );
isset( $this->mNamespaceNames[$code] ) &&
isset( $this->mNamespaceAliases[$code] ) &&
isset( $this->mMagicWords[$code] ) &&
- isset( $this->mSpecialPageAliases[$code] ) ) {
+ isset( $this->mSpecialPageAliases[$code] )
+ ) {
return;
}
$this->mRawMessages[$code] = array();
$this->mSpecialPageAliases[$code] = array();
$filename = Language::getMessagesFileName( $code );
if ( file_exists( $filename ) ) {
- require( $filename );
+ require $filename;
if ( isset( $messages ) ) {
$this->mRawMessages[$code] = $messages;
}
}
/**
- * Load the messages for a specific language (which is not English) and divide them to groups:
+ * Load the messages for a specific language (which is not English) and divide them to
+ * groups:
* all - all the messages.
* required - messages which should be translated in order to get a complete translation.
- * optional - messages which can be translated, the fallback translation is used if not translated.
- * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages.
- * translated - messages which are either required or optional, but translated from English and needed.
+ * optional - messages which can be translated, the fallback translation is used if not
+ * translated.
+ * obsolete - messages which should not be translated, either because they do not exist,
+ * or they are ignored messages.
+ * translated - messages which are either required or optional, but translated from
+ * English and needed.
*
* @param $code string The language code.
*/
/**
* Load the messages for English and divide them to groups:
* all - all the messages.
- * required - messages which should be translated to other languages in order to get a complete translation.
- * optional - messages which can be translated to other languages, but it's not required for a complete translation.
+ * required - messages which should be translated to other languages in order to get a
+ * complete translation.
+ * optional - messages which can be translated to other languages, but it's not required
+ * for a complete translation.
* ignored - messages which should not be translated to other languages.
- * translatable - messages which are either required or optional, but can be translated from English.
+ * translatable - messages which are either required or optional, but can be translated
+ * from English.
*/
private function loadGeneralMessages() {
if ( isset( $this->mGeneralMessages ) ) {
* fallback language messages, divided to groups:
* all - all the messages.
* required - messages which should be translated in order to get a complete translation.
- * optional - messages which can be translated, the fallback translation is used if not translated.
- * obsolete - messages which should not be translated, either because they do not exist, or they are ignored messages.
- * translated - messages which are either required or optional, but translated from English and needed.
+ * optional - messages which can be translated, the fallback translation is used if not
+ * translated.
+ * obsolete - messages which should not be translated, either because they do not exist,
+ * or they are ignored messages.
+ * translated - messages which are either required or optional, but translated from
+ * English and needed.
*
* @param $code string The language code.
*
*/
public function getMessages( $code ) {
$this->loadMessages( $code );
+
return $this->mMessages[$code];
}
/**
* Get all the general English messages, divided to groups:
* all - all the messages.
- * required - messages which should be translated to other languages in order to get a complete translation.
- * optional - messages which can be translated to other languages, but it's not required for a complete translation.
+ * required - messages which should be translated to other languages in
+ * order to get a complete translation.
+ * optional - messages which can be translated to other languages, but it's
+ * not required for a complete translation.
* ignored - messages which should not be translated to other languages.
- * translatable - messages which are either required or optional, but can be translated from English.
+ * translatable - messages which are either required or optional, but can be
+ * translated from English.
*
* @return array The general English messages.
*/
public function getGeneralMessages() {
$this->loadGeneralMessages();
+
return $this->mGeneralMessages;
}
*/
public function getFallback( $code ) {
$this->loadFile( $code );
+
return $this->mFallback[$code];
}
*/
public function getNamespaceNames( $code ) {
$this->loadFile( $code );
+
return $this->mNamespaceNames[$code];
}
*/
public function getNamespaceAliases( $code ) {
$this->loadFile( $code );
+
return $this->mNamespaceAliases[$code];
}
*/
public function getMagicWords( $code ) {
$this->loadFile( $code );
+
return $this->mMagicWords[$code];
}
*/
public function getSpecialPageAliases( $code ) {
$this->loadFile( $code );
+
return $this->mSpecialPageAliases[$code];
}
public function getUntranslatedMessages( $code ) {
$this->loadGeneralMessages();
$this->loadMessages( $code );
+
return array_diff_key( $this->mGeneralMessages['required'], $this->mMessages[$code]['required'] );
}
$duplicateMessages[$key] = $value;
}
}
+
return $duplicateMessages;
}
public function getObsoleteMessages( $code ) {
$this->loadGeneralMessages();
$this->loadMessages( $code );
+
return $this->mMessages[$code]['obsolete'];
}
$missing = false;
foreach ( $variables as $var ) {
if ( preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
- !preg_match( "/$var/sU", $value ) ) {
+ !preg_match( "/$var/sU", $value )
+ ) {
$missing = true;
}
if ( !preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
- preg_match( "/$var/sU", $value ) ) {
+ preg_match( "/$var/sU", $value )
+ ) {
$missing = true;
}
}
$mismatchMessages[$key] = $value;
}
}
+
return $mismatchMessages;
}
$this->loadMessages( $code );
$messagesWithoutPlural = array();
foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
- if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false && stripos( $value, '{{plural:' ) === false ) {
+ if ( stripos( $this->mGeneralMessages['translatable'][$key], '{{plural:' ) !== false &&
+ stripos( $value, '{{plural:' ) === false
+ ) {
$messagesWithoutPlural[$key] = $value;
}
}
+
return $messagesWithoutPlural;
}
$emptyMessages[$key] = $value;
}
}
+
return $emptyMessages;
}
$messagesWithWhitespace[$key] = $value;
}
}
+
return $messagesWithWhitespace;
}
$nonXHTMLMessages[$key] = $value;
}
}
+
return $nonXHTMLMessages;
}
$wrongCharsMessages[$key] = $value;
}
}
+
return $wrongCharsMessages;
}
foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
$matches = array();
preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches );
- for ( $i = 0; $i < count( $matches[0] ); $i++ ) {
+ $numMatches = count( $matches[0] );
+ for ( $i = 0; $i < $numMatches; $i++ ) {
if ( preg_match( "/.*project.*/isDu", $matches[1][$i] ) ) {
$messages[$key][] = $matches[0][$i];
}
}
-
if ( isset( $messages[$key] ) ) {
$messages[$key] = implode( $messages[$key], ", " );
}
}
+
return $messages;
}
if ( $a !== $b || $c !== $d ) {
$messages[$key] = "$a, $b, $c, $d";
}
-
}
+
return $messages;
}
if ( isset( $namespacesDiff[NS_MAIN] ) ) {
unset( $namespacesDiff[NS_MAIN] );
}
+
return $namespacesDiff;
}
$magicWords[$key] = $value[1];
}
}
+
return $magicWords;
}
$magicWords[$key] = $value[1];
}
}
+
return $magicWords;
}
}
}
}
+
return $magicWords;
}
$magicWords[$key] = $local[0];
}
}
+
return $magicWords;
}
$specialPageAliases[$key] = $value[0];
}
}
+
return $specialPageAliases;
}
$specialPageAliases[$key] = $value[0];
}
}
+
return $specialPageAliases;
}
}
-class extensionLanguages extends languages {
-
+class ExtensionLanguages extends Languages {
/**
* @var MessageGroup
*/