class Language {
var $mConverter, $mVariants, $mCode, $mLoaded = false;
+ var $mMagicExtensions = array(), $mMagicHookDone = false;
static public $mLocalisationKeys = array( 'fallback', 'namespaceNames',
'skinNames', 'mathNames',
# Fill a MagicWord object with data from here
function getMagic( &$mw ) {
- if ( !isset( $this->mMagicExtensions ) ) {
- $this->mMagicExtensions = array();
+ if ( !$this->mMagicHookDone ) {
+ $this->mMagicHookDone = true;
wfRunHooks( 'LanguageGetMagic', array( &$this->mMagicExtensions, $this->getCode() ) );
}
if ( isset( $this->mMagicExtensions[$mw->mId] ) ) {
$mw->mSynonyms = array_slice( $rawEntry, 1 );
}
+ /**
+ * Add magic words to the extension array
+ */
+ function addMagicWordsByLang( $newWords ) {
+ $code = $this->getCode();
+ $fallbackChain = array();
+ while ( $code && !in_array( $code, $fallbackChain ) ) {
+ $fallbackChain[] = $code;
+ $code = self::getFallbackFor( $code );
+ }
+ $fallbackChain = array_reverse( $fallbackChain );
+ foreach ( $fallbackChain as $code ) {
+ if ( isset( $newWords[$code] ) ) {
+ $this->mMagicExtensions = $newWords[$code] + $this->mMagicExtensions;
+ }
+ }
+ }
+
/**
* Get special page names, as an associative array
* case folded alias => real name