/**
* Handle messages in the language files.
*
- * @package MediaWiki
- * @subpackage Maintenance
+ * @file
+ * @ingroup MaintenanceLanguage
*/
+/**
+ * @ingroup MaintenanceLanguage
+ */
class languages {
- private $mLanguages; # List of languages
- private $mRawMessages; # Raw list of the messages in each language
- private $mMessages; # Messages in each language (except for English), divided to groups
- private $mGeneralMessages; # General messages in English, divided to groups
- private $mIgnoredMessages = array(
- 'sidebar',
- 'addsection',
- 'anonnotice',
- 'catseparator',
- 'googlesearch',
- 'exif-make-value',
- 'exif-model-value',
- 'exif-software-value',
- 'history_copyright',
- 'licenses',
- 'loginend',
- 'loginlanguagelinks',
- 'markaspatrolledlink',
- 'newarticletextanon',
- 'noarticletextanon',
- 'number_of_watching_users_RCview',
- 'pubmedurl',
- 'randompage-url',
- 'recentchanges-url',
- 'rfcurl',
- 'shareddescriptionfollows',
- 'signupend',
- 'sitenotice',
- 'sitesubtitle',
- 'sitetitle',
- 'talkpagetext',
- 'trackback',
- 'trackbackexcerpt',
- 'widthheight',
- ); # All the messages which should be exist only in the English file
- private $mOptionalMessages = array(
- 'imgmultigotopost',
- 'linkprefix',
- 'allpages-summary',
- 'booksources-summary',
- 'ipblocklist-summary',
- 'listusers-summary',
- 'longpages-summary',
- 'preferences-summary',
- 'specialpages-summary',
- 'whatlinkshere-summary',
- ); # All the messages which may be translated or not, depending on the language
- private $mEXIFMessages = array(
- 'exif-imagewidth',
- 'exif-imagelength',
- 'exif-bitspersample',
- 'exif-compression',
- 'exif-photometricinterpretation',
- 'exif-orientation',
- 'exif-samplesperpixel',
- 'exif-planarconfiguration',
- 'exif-ycbcrsubsampling',
- 'exif-ycbcrpositioning',
- 'exif-xresolution',
- 'exif-yresolution',
- 'exif-resolutionunit',
- 'exif-stripoffsets',
- 'exif-rowsperstrip',
- 'exif-stripbytecounts',
- 'exif-jpeginterchangeformat',
- 'exif-jpeginterchangeformatlength',
- 'exif-transferfunction',
- 'exif-whitepoint',
- 'exif-primarychromaticities',
- 'exif-ycbcrcoefficients',
- 'exif-referenceblackwhite',
- 'exif-datetime',
- 'exif-imagedescription',
- 'exif-make',
- 'exif-model',
- 'exif-software',
- 'exif-artist',
- 'exif-copyright',
- 'exif-exifversion',
- 'exif-flashpixversion',
- 'exif-colorspace',
- 'exif-componentsconfiguration',
- 'exif-compressedbitsperpixel',
- 'exif-pixelydimension',
- 'exif-pixelxdimension',
- 'exif-makernote',
- 'exif-usercomment',
- 'exif-relatedsoundfile',
- 'exif-datetimeoriginal',
- 'exif-datetimedigitized',
- 'exif-subsectime',
- 'exif-subsectimeoriginal',
- 'exif-subsectimedigitized',
- 'exif-exposuretime',
- 'exif-exposuretime-format',
- 'exif-fnumber',
- 'exif-fnumber-format',
- 'exif-exposureprogram',
- 'exif-spectralsensitivity',
- 'exif-isospeedratings',
- 'exif-oecf',
- 'exif-shutterspeedvalue',
- 'exif-aperturevalue',
- 'exif-brightnessvalue',
- 'exif-exposurebiasvalue',
- 'exif-maxaperturevalue',
- 'exif-subjectdistance',
- 'exif-meteringmode',
- 'exif-lightsource',
- 'exif-flash',
- 'exif-focallength',
- 'exif-focallength-format',
- 'exif-subjectarea',
- 'exif-flashenergy',
- 'exif-spatialfrequencyresponse',
- 'exif-focalplanexresolution',
- 'exif-focalplaneyresolution',
- 'exif-focalplaneresolutionunit',
- 'exif-subjectlocation',
- 'exif-exposureindex',
- 'exif-sensingmethod',
- 'exif-filesource',
- 'exif-scenetype',
- 'exif-cfapattern',
- 'exif-customrendered',
- 'exif-exposuremode',
- 'exif-whitebalance',
- 'exif-digitalzoomratio',
- 'exif-focallengthin35mmfilm',
- 'exif-scenecapturetype',
- 'exif-gaincontrol',
- 'exif-contrast',
- 'exif-saturation',
- 'exif-sharpness',
- 'exif-devicesettingdescription',
- 'exif-subjectdistancerange',
- 'exif-imageuniqueid',
- 'exif-gpsversionid',
- 'exif-gpslatituderef',
- 'exif-gpslatitude',
- 'exif-gpslongituderef',
- 'exif-gpslongitude',
- 'exif-gpsaltituderef',
- 'exif-gpsaltitude',
- 'exif-gpstimestamp',
- 'exif-gpssatellites',
- 'exif-gpsstatus',
- 'exif-gpsmeasuremode',
- 'exif-gpsdop',
- 'exif-gpsspeedref',
- 'exif-gpsspeed',
- 'exif-gpstrackref',
- 'exif-gpstrack',
- 'exif-gpsimgdirectionref',
- 'exif-gpsimgdirection',
- 'exif-gpsmapdatum',
- 'exif-gpsdestlatituderef',
- 'exif-gpsdestlatitude',
- 'exif-gpsdestlongituderef',
- 'exif-gpsdestlongitude',
- 'exif-gpsdestbearingref',
- 'exif-gpsdestbearing',
- 'exif-gpsdestdistanceref',
- 'exif-gpsdestdistance',
- 'exif-gpsprocessingmethod',
- 'exif-gpsareainformation',
- 'exif-gpsdatestamp',
- 'exif-gpsdifferential',
- 'exif-compression-1',
- 'exif-compression-6',
- 'exif-photometricinterpretation-2',
- 'exif-photometricinterpretation-6',
- 'exif-orientation-1',
- 'exif-orientation-2',
- 'exif-orientation-3',
- 'exif-orientation-4',
- 'exif-orientation-5',
- 'exif-orientation-6',
- 'exif-orientation-7',
- 'exif-orientation-8',
- 'exif-planarconfiguration-1',
- 'exif-planarconfiguration-2',
- 'exif-xyresolution-i',
- 'exif-xyresolution-c',
- 'exif-colorspace-1',
- 'exif-colorspace-ffff.h',
- 'exif-componentsconfiguration-0',
- 'exif-componentsconfiguration-1',
- 'exif-componentsconfiguration-2',
- 'exif-componentsconfiguration-3',
- 'exif-componentsconfiguration-4',
- 'exif-componentsconfiguration-5',
- 'exif-componentsconfiguration-6',
- 'exif-exposureprogram-0',
- 'exif-exposureprogram-1',
- 'exif-exposureprogram-2',
- 'exif-exposureprogram-3',
- 'exif-exposureprogram-4',
- 'exif-exposureprogram-5',
- 'exif-exposureprogram-6',
- 'exif-exposureprogram-7',
- 'exif-exposureprogram-8',
- 'exif-subjectdistance-value',
- 'exif-meteringmode-0',
- 'exif-meteringmode-1',
- 'exif-meteringmode-2',
- 'exif-meteringmode-3',
- 'exif-meteringmode-4',
- 'exif-meteringmode-5',
- 'exif-meteringmode-6',
- 'exif-meteringmode-255',
- 'exif-lightsource-0',
- 'exif-lightsource-1',
- 'exif-lightsource-2',
- 'exif-lightsource-3',
- 'exif-lightsource-4',
- 'exif-lightsource-9',
- 'exif-lightsource-10',
- 'exif-lightsource-11',
- 'exif-lightsource-12',
- 'exif-lightsource-13',
- 'exif-lightsource-14',
- 'exif-lightsource-15',
- 'exif-lightsource-17',
- 'exif-lightsource-18',
- 'exif-lightsource-19',
- 'exif-lightsource-20',
- 'exif-lightsource-21',
- 'exif-lightsource-22',
- 'exif-lightsource-23',
- 'exif-lightsource-24',
- 'exif-lightsource-255',
- 'exif-focalplaneresolutionunit-2',
- 'exif-sensingmethod-1',
- 'exif-sensingmethod-2',
- 'exif-sensingmethod-3',
- 'exif-sensingmethod-4',
- 'exif-sensingmethod-5',
- 'exif-sensingmethod-7',
- 'exif-sensingmethod-8',
- 'exif-filesource-3',
- 'exif-scenetype-1',
- 'exif-customrendered-0',
- 'exif-customrendered-1',
- 'exif-exposuremode-0',
- 'exif-exposuremode-1',
- 'exif-exposuremode-2',
- 'exif-whitebalance-0',
- 'exif-whitebalance-1',
- 'exif-scenecapturetype-0',
- 'exif-scenecapturetype-1',
- 'exif-scenecapturetype-2',
- 'exif-scenecapturetype-3',
- 'exif-gaincontrol-0',
- 'exif-gaincontrol-1',
- 'exif-gaincontrol-2',
- 'exif-gaincontrol-3',
- 'exif-gaincontrol-4',
- 'exif-contrast-0',
- 'exif-contrast-1',
- 'exif-contrast-2',
- 'exif-saturation-0',
- 'exif-saturation-1',
- 'exif-saturation-2',
- 'exif-sharpness-0',
- 'exif-sharpness-1',
- 'exif-sharpness-2',
- 'exif-subjectdistancerange-0',
- 'exif-subjectdistancerange-1',
- 'exif-subjectdistancerange-2',
- 'exif-subjectdistancerange-3',
- 'exif-gpslatitude-n',
- 'exif-gpslatitude-s',
- 'exif-gpslongitude-e',
- 'exif-gpslongitude-w',
- 'exif-gpsstatus-a',
- 'exif-gpsstatus-v',
- 'exif-gpsmeasuremode-2',
- 'exif-gpsmeasuremode-3',
- 'exif-gpsspeed-k',
- 'exif-gpsspeed-m',
- 'exif-gpsspeed-n',
- 'exif-gpsdirection-t',
- 'exif-gpsdirection-m',
- ); # All the EXIF messages, may be set as optional if defined as such
+ protected $mLanguages; # List of languages
+
+ 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
+
+ protected $mNamespaceNames; # Namespace names
+ protected $mNamespaceAliases; # Namespace aliases
+ protected $mMagicWords; # Magic words
+ protected $mSpecialPageAliases; # Special page aliases
/**
* Load the list of languages: all the Messages*.php
* @param $exif Treat the EXIF messages?
*/
function __construct( $exif = true ) {
+ require( dirname(__FILE__) . '/messageTypes.inc' );
+ $this->mIgnoredMessages = $wgIgnoredMessages;
+ if ( $exif ) {
+ $this->mOptionalMessages = array_merge( $wgOptionalMessages );
+ } else {
+ $this->mOptionalMessages = array_merge( $wgOptionalMessages, $wgEXIFMessages );
+ }
+
$this->mLanguages = array_keys( Language::getLanguageNames( true ) );
sort( $this->mLanguages );
- if ( !$exif ) {
- $this->mOptionalMessages = array_merge( $this->mOptionalMessages, $this->mEXIFMessages );
- }
}
/**
}
/**
- * Load the raw messages for a specific langauge from the messages file.
+ * Get the ignored messages list.
*
- * @param $code The langauge code.
+ * @return The ignored messages list.
*/
- private function loadRawMessages( $code ) {
- if ( isset( $this->mRawMessages[$code] ) ) {
+ public function getIgnoredMessages() {
+ return $this->mIgnoredMessages;
+ }
+
+ /**
+ * Get the optional messages list.
+ *
+ * @return The optional messages list.
+ */
+ public function getOptionalMessages() {
+ return $this->mOptionalMessages;
+ }
+
+ /**
+ * Load the language file.
+ *
+ * @param $code The language code.
+ */
+ protected function loadFile( $code ) {
+ if ( isset( $this->mRawMessages[$code] ) &&
+ isset( $this->mFallback[$code] ) &&
+ isset( $this->mNamespaceNames[$code] ) &&
+ isset( $this->mNamespaceAliases[$code] ) &&
+ isset( $this->mMagicWords[$code] ) &&
+ isset( $this->mSpecialPageAliases[$code] ) ) {
return;
}
+ $this->mRawMessages[$code] = array();
+ $this->mFallback[$code] = '';
+ $this->mNamespaceNames[$code] = array();
+ $this->mNamespaceAliases[$code] = array();
+ $this->mMagicWords[$code] = array();
+ $this->mSpecialPageAliases[$code] = array();
$filename = Language::getMessagesFileName( $code );
if ( file_exists( $filename ) ) {
require( $filename );
if ( isset( $messages ) ) {
$this->mRawMessages[$code] = $messages;
- } else {
- $this->mRawMessages[$code] = array();
}
- } else {
- $this->mRawMessages[$code] = array();
+ if ( isset( $fallback ) ) {
+ $this->mFallback[$code] = $fallback;
+ }
+ if ( isset( $namespaceNames ) ) {
+ $this->mNamespaceNames[$code] = $namespaceNames;
+ }
+ if ( isset( $namespaceAliases ) ) {
+ $this->mNamespaceAliases[$code] = $namespaceAliases;
+ }
+ if ( isset( $magicWords ) ) {
+ $this->mMagicWords[$code] = $magicWords;
+ }
+ if ( isset( $specialPageAliases ) ) {
+ $this->mSpecialPageAliases[$code] = $specialPageAliases;
+ }
}
}
* 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 are not exist, or they are ignored messages.
+ * 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 The language code.
if ( isset( $this->mMessages[$code] ) ) {
return;
}
- $this->loadRawMessages( $code );
+ $this->loadFile( $code );
$this->loadGeneralMessages();
$this->mMessages[$code]['all'] = $this->mRawMessages[$code];
$this->mMessages[$code]['required'] = array();
if ( isset( $this->mGeneralMessages ) ) {
return;
}
- $this->loadRawMessages( 'en' );
+ $this->loadFile( 'en' );
$this->mGeneralMessages['all'] = $this->mRawMessages['en'];
$this->mGeneralMessages['required'] = array();
$this->mGeneralMessages['optional'] = array();
}
/**
- * Get all the messages for a specific langauge (not English), without the
+ * Get all the messages for a specific language (not English), without the
* 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 are not exist, or they are ignored messages.
+ * 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 The langauge code.
+ * @param $code The language code.
*
* @return The messages in this language.
*/
return $this->mGeneralMessages;
}
+ /**
+ * Get fallback language code for a specific language.
+ *
+ * @param $code The language code.
+ *
+ * @return Fallback code.
+ */
+ public function getFallback( $code ) {
+ $this->loadFile( $code );
+ return $this->mFallback[$code];
+ }
+
+ /**
+ * Get namespace names for a specific language.
+ *
+ * @param $code The language code.
+ *
+ * @return Namespace names.
+ */
+ public function getNamespaceNames( $code ) {
+ $this->loadFile( $code );
+ return $this->mNamespaceNames[$code];
+ }
+
+ /**
+ * Get namespace aliases for a specific language.
+ *
+ * @param $code The language code.
+ *
+ * @return Namespace aliases.
+ */
+ public function getNamespaceAliases( $code ) {
+ $this->loadFile( $code );
+ return $this->mNamespaceAliases[$code];
+ }
+
+ /**
+ * Get magic words for a specific language.
+ *
+ * @param $code The language code.
+ *
+ * @return Magic words.
+ */
+ public function getMagicWords( $code ) {
+ $this->loadFile( $code );
+ return $this->mMagicWords[$code];
+ }
+
+ /**
+ * Get special page aliases for a specific language.
+ *
+ * @param $code The language code.
+ *
+ * @return Special page aliases.
+ */
+ public function getSpecialPageAliases( $code ) {
+ $this->loadFile( $code );
+ return $this->mSpecialPageAliases[$code];
+ }
+
/**
* Get the untranslated messages for a specific language.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The untranslated messages for this language.
*/
public function getUntranslatedMessages( $code ) {
$this->loadGeneralMessages();
$this->loadMessages( $code );
- $requiredGeneralMessages = array_keys( $this->mGeneralMessages['required'] );
- $requiredMessages = array_keys( $this->mMessages[$code]['required'] );
- $untranslatedMessages = array();
- foreach ( array_diff( $requiredGeneralMessages, $requiredMessages ) as $key ) {
- $untranslatedMessages[$key] = $this->mGeneralMessages['required'][$key];
- }
- return $untranslatedMessages;
+ return array_diff_key( $this->mGeneralMessages['required'], $this->mMessages[$code]['required'] );
}
/**
* Get the duplicate messages for a specific language.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The duplicate messages for this language.
*/
}
/**
- * Get the messages which do not use some variables.
+ * Get the obsolete messages for a specific language.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
- * @return The messages which do not use some variables in this language.
+ * @return The obsolete messages for this language.
*/
- public function getMessagesWithoutVariables( $code ) {
+ public function getObsoleteMessages( $code ) {
+ $this->loadGeneralMessages();
+ $this->loadMessages( $code );
+ return $this->mMessages[$code]['obsolete'];
+ }
+
+ /**
+ * Get the messages whose variables do not match the original ones.
+ *
+ * @param $code The language code.
+ *
+ * @return The messages whose variables do not match the original ones.
+ */
+ public function getMessagesWithMismatchVariables( $code ) {
$this->loadGeneralMessages();
$this->loadMessages( $code );
$variables = array( '\$1', '\$2', '\$3', '\$4', '\$5', '\$6', '\$7', '\$8', '\$9' );
- $messagesWithoutVariables = array();
+ $mismatchMessages = array();
foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
$missing = false;
foreach ( $variables as $var ) {
!preg_match( "/$var/sU", $value ) ) {
$missing = true;
}
+ if ( !preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
+ preg_match( "/$var/sU", $value ) ) {
+ $missing = true;
+ }
}
if ( $missing ) {
- $messagesWithoutVariables[$key] = $value;
+ $mismatchMessages[$key] = $value;
+ }
+ }
+ return $mismatchMessages;
+ }
+
+ /**
+ * Get the messages which do not use plural.
+ *
+ * @param $code The language code.
+ *
+ * @return The messages which do not use plural in this language.
+ */
+ public function getMessagesWithoutPlural( $code ) {
+ $this->loadGeneralMessages();
+ $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 ) {
+ $messagesWithoutPlural[$key] = $value;
}
}
- return $messagesWithoutVariables;
+ return $messagesWithoutPlural;
}
/**
* Get the empty messages.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The empty messages for this language.
*/
/**
* Get the messages with trailing whitespace.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages with trailing whitespace in this language.
*/
/**
* Get the non-XHTML messages.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The non-XHTML messages for this language.
*/
'<br *\\?>',
'<hr/>',
'<br/>',
+ '<hr>',
+ '<br>',
);
$wrongPhrases = '~(' . implode( '|', $wrongPhrases ) . ')~sDu';
$nonXHTMLMessages = array();
/**
* Get the messages which include wrong characters.
*
- * @param $code The langauge code.
+ * @param $code The language code.
*
* @return The messages which include wrong characters in this language.
*/
}
/**
- * Output a messages list
+ * Get the messages which include dubious links.
*
- * @param $messages The messages list
- * @param $code The language code
- * @param $text The text to show before the list (optional)
- * @param $level The display level (optional)
- * @param $links Show links (optional)
- * @param $wikilang The langauge of the wiki to display the list in, for the links (optional)
+ * @param $code The language code.
+ *
+ * @return The messages which include dubious links in this language.
*/
- public function outputMessagesList( $messages, $code, $text = '', $level = 2, $links = false, $wikilang = null ) {
- if ( count( $messages ) == 0 ) {
- return;
- }
- if ( $text ) {
- echo "$text\n";
+ public function getMessagesWithDubiousLinks( $code ) {
+ $this->loadGeneralMessages();
+ $this->loadMessages( $code );
+ $tc = Title::legalChars() . '#%{}';
+ $messages = array();
+ 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++ ) {
+ if ( preg_match( "/.*project.*/isDu", $matches[1][$i] ) ) {
+ $messages[$key][] = $matches[0][$i];
+ }
+ }
+
+
+ if ( isset( $messages[$key] ) ) {
+ $messages[$key] = implode( $messages[$key],", " );
+ }
}
- if ( $level == 1 ) {
- echo "[messages are hidden]\n";
- } else {
- foreach ( $messages as $key => $value ) {
- if ( $links ) {
- $displayKey = ucfirst( $key );
- if ( !isset( $wikilang ) ) {
- global $wgContLang;
- $wikilang = $wgContLang->getCode();
- }
- if ( $code == $wikilang ) {
- $displayKey = "[[MediaWiki:$displayKey|$key]]";
- } else {
- $displayKey = "[[MediaWiki:$displayKey/$code|$key]]";
- }
- } else {
- $displayKey = $key;
+ return $messages;
+ }
+
+ /**
+ * Get the messages which include unbalanced brackets.
+ *
+ * @param $code The language code.
+ *
+ * @return The messages which include unbalanced brackets in this language.
+ */
+ public function getMessagesWithUnbalanced( $code ) {
+ $this->loadGeneralMessages();
+ $this->loadMessages( $code );
+ $messages = array();
+ foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
+ $a = $b = $c = $d = 0;
+ foreach ( preg_split( '//', $value ) as $char ) {
+ switch ( $char ) {
+ case '[':
+ $a++;
+ break;
+ case ']':
+ $b++;
+ break;
+ case '{':
+ $c++;
+ break;
+ case '}':
+ $d++;
+ break;
}
- if ( $level == 2 ) {
- echo "* $displayKey\n";
- } else {
- echo "* $displayKey: '$value'\n";
+ }
+
+ if ( $a !== $b || $c !== $d ) {
+ $messages[$key] = "$a, $b, $c, $d";
+ }
+
+ }
+ return $messages;
+ }
+
+ /**
+ * Get the untranslated namespace names.
+ *
+ * @param $code The language code.
+ *
+ * @return The untranslated namespace names in this language.
+ */
+ public function getUntranslatedNamespaces( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ return array_flip( array_diff_key( $this->mNamespaceNames['en'], $this->mNamespaceNames[$code] ) );
+ }
+
+ /**
+ * Get the project talk namespace names with no $1.
+ *
+ * @param $code The language code.
+ *
+ * @return The problematic project talk namespaces in this language.
+ */
+ public function getProblematicProjectTalks( $code ) {
+ $this->loadFile( $code );
+ $namespaces = array();
+
+ # Check default namespace name
+ if( isset( $this->mNamespaceNames[$code][NS_PROJECT_TALK] ) ) {
+ $default = $this->mNamespaceNames[$code][NS_PROJECT_TALK];
+ if ( strpos( $default, '$1' ) === FALSE ) {
+ $namespaces[$default] = 'default';
+ }
+ }
+
+ # Check namespace aliases
+ foreach( $this->mNamespaceAliases[$code] as $key => $value ) {
+ if ( $value == NS_PROJECT_TALK && strpos( $key, '$1' ) === FALSE ) {
+ $namespaces[$key] = '';
+ }
+ }
+
+ return $namespaces;
+ }
+
+ /**
+ * Get the untranslated magic words.
+ *
+ * @param $code The language code.
+ *
+ * @return The untranslated magic words in this language.
+ */
+ public function getUntranslatedMagicWords( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ $magicWords = array();
+ foreach ( $this->mMagicWords['en'] as $key => $value ) {
+ if ( !isset( $this->mMagicWords[$code][$key] ) ) {
+ $magicWords[$key] = $value[1];
+ }
+ }
+ return $magicWords;
+ }
+
+ /**
+ * Get the obsolete magic words.
+ *
+ * @param $code The language code.
+ *
+ * @return The obsolete magic words in this language.
+ */
+ public function getObsoleteMagicWords( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ $magicWords = array();
+ foreach ( $this->mMagicWords[$code] as $key => $value ) {
+ if ( !isset( $this->mMagicWords['en'][$key] ) ) {
+ $magicWords[$key] = $value[1];
+ }
+ }
+ return $magicWords;
+ }
+
+ /**
+ * Get the magic words that override the original English magic word.
+ *
+ * @param $code The language code.
+ *
+ * @return The overriding magic words in this language.
+ */
+ public function getOverridingMagicWords( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ $magicWords = array();
+ foreach ( $this->mMagicWords[$code] as $key => $local ) {
+ if ( !isset( $this->mMagicWords['en'][$key] ) ) {
+ # Unrecognized magic word
+ continue;
+ }
+ $en = $this->mMagicWords['en'][$key];
+ array_shift( $local );
+ array_shift( $en );
+ foreach ( $en as $word ) {
+ if ( !in_array( $word, $local ) ) {
+ $magicWords[$key] = $word;
+ break;
}
}
}
+ return $magicWords;
+ }
+
+ /**
+ * Get the magic words which do not match the case-sensitivity of the original words.
+ *
+ * @param $code The language code.
+ *
+ * @return The magic words whose case does not match in this language.
+ */
+ public function getCaseMismatchMagicWords( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ $magicWords = array();
+ foreach ( $this->mMagicWords[$code] as $key => $local ) {
+ if ( !isset( $this->mMagicWords['en'][$key] ) ) {
+ # Unrecognized magic word
+ continue;
+ }
+ if ( $local[0] != $this->mMagicWords['en'][$key][0] ) {
+ $magicWords[$key] = $local[0];
+ }
+ }
+ return $magicWords;
+ }
+
+ /**
+ * Get the untranslated special page names.
+ *
+ * @param $code The language code.
+ *
+ * @return The untranslated special page names in this language.
+ */
+ public function getUntraslatedSpecialPages( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ $specialPageAliases = array();
+ foreach ( $this->mSpecialPageAliases['en'] as $key => $value ) {
+ if ( !isset( $this->mSpecialPageAliases[$code][$key] ) ) {
+ $specialPageAliases[$key] = $value[0];
+ }
+ }
+ return $specialPageAliases;
+ }
+
+ /**
+ * Get the obsolete special page names.
+ *
+ * @param $code The language code.
+ *
+ * @return The obsolete special page names in this language.
+ */
+ public function getObsoleteSpecialPages( $code ) {
+ $this->loadFile( 'en' );
+ $this->loadFile( $code );
+ $specialPageAliases = array();
+ foreach ( $this->mSpecialPageAliases[$code] as $key => $value ) {
+ if ( !isset( $this->mSpecialPageAliases['en'][$key] ) ) {
+ $specialPageAliases[$key] = $value[0];
+ }
+ }
+ return $specialPageAliases;
}
}
-?>
+class extensionLanguages extends languages {
+ private $mMessageGroup; # The message group
+
+ /**
+ * Load the messages group.
+ * @param $group The messages group.
+ */
+ function __construct( MessageGroup $group ) {
+ $this->mMessageGroup = $group;
+
+ $bools = $this->mMessageGroup->getBools();
+ $this->mIgnoredMessages = $bools['ignored'];
+ $this->mOptionalMessages = $bools['optional'];
+ }
+
+ /**
+ * Get the extension name.
+ *
+ * @return The extension name.
+ */
+ public function name() {
+ return $this->mMessageGroup->getLabel();
+ }
+
+ /**
+ * Load the language file.
+ *
+ * @param $code The language code.
+ */
+ protected function loadFile( $code ) {
+ if( !isset( $this->mRawMessages[$code] ) ) {
+ $this->mRawMessages[$code] = $this->mMessageGroup->load( $code );
+ if( empty( $this->mRawMessages[$code] ) ) {
+ $this->mRawMessages[$code] = array();
+ }
+ }
+ }
+}