* For constructor parameters, see the documentation in DefaultSettings.php
* for $wgLocalisationCacheConf.
*
- * @param $conf Array
+ * @param array $conf
* @throws MWException
*/
function __construct( $conf ) {
/**
* Returns true if the given key is mergeable, that is, if it is an associative
* array which can be merged through a fallback sequence.
- * @param $key
+ * @param string $key
* @return bool
*/
public function isMergeableKey( $key ) {
*
* Warning: this may be slow for split items (messages), since it will
* need to fetch all of the subitems from the cache individually.
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
* @return mixed
*/
public function getItem( $code, $key ) {
/**
* Get a subitem, for instance a single message for a given language.
- * @param $code
- * @param $key
- * @param $subkey
- * @return null
+ * @param string $code
+ * @param string $key
+ * @param string $subkey
+ * @return mixed|null
*/
public function getSubitem( $code, $key, $subkey ) {
if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) &&
*
* Will return null if the item is not found, or false if the item is not an
* array.
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
* @return bool|null|string
*/
public function getSubitemList( $code, $key ) {
/**
* Load an item into the cache.
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
*/
protected function loadItem( $code, $key ) {
if ( !isset( $this->initialisedLangs[$code] ) ) {
/**
* Load a subitem into the cache
- * @param $code
- * @param $key
- * @param $subkey
+ * @param string $code
+ * @param string $key
+ * @param string $subkey
*/
protected function loadSubitem( $code, $key, $subkey ) {
if ( !in_array( $key, self::$splitKeys ) ) {
/**
* Initialise a language in this object. Rebuild the cache if necessary.
- * @param $code
+ * @param string $code
* @throws MWException
*/
protected function initLanguage( $code ) {
/**
* Create a fallback from one language to another, without creating a
* complete persistent cache.
- * @param $primaryCode
- * @param $fallbackCode
+ * @param string $primaryCode
+ * @param string $fallbackCode
*/
public function initShallowFallback( $primaryCode, $fallbackCode ) {
$this->data[$primaryCode] =& $this->data[$fallbackCode];
/**
* Read a PHP file containing localisation data.
- * @param $_fileName
- * @param $_fileType
+ * @param string $_fileName
+ * @param string $_fileType
* @throws MWException
* @return array
*/
* Read a JSON file containing localisation messages.
* @param string $fileName Name of file to read
* @throws MWException if there is a syntax error in the JSON file
- * @return array with a 'messages' key, or empty array if the file doesn't exist
+ * @return array Array with a 'messages' key, or empty array if the file doesn't exist
*/
- protected function readJSONFile( $fileName ) {
+ public function readJSONFile( $fileName ) {
wfProfileIn( __METHOD__ );
if ( !is_readable( $fileName ) ) {
/**
* Get the compiled plural rules for a given language from the XML files.
* @since 1.20
+ * @param string $code
+ * @return array|null
*/
public function getCompiledPluralRules( $code ) {
$rules = $this->getPluralRules( $code );
* Get the plural rules for a given language from the XML files.
* Cached.
* @since 1.20
+ * @param string $code
+ * @return array|null
*/
public function getPluralRules( $code ) {
if ( $this->pluralRules === null ) {
* Get the plural rule types for a given language from the XML files.
* Cached.
* @since 1.22
+ * @param string $code
+ * @return array|null
*/
public function getPluralRuleTypes( $code ) {
if ( $this->pluralRuleTypes === null ) {
/**
* Load a plural XML file with the given filename, compile the relevant
* rules, and save the compiled rules in a process-local cache.
+ *
+ * @param string $fileName
*/
protected function loadPluralFile( $fileName ) {
$doc = new DOMDocument;
* Read the data from the source files for a given language, and register
* the relevant dependencies in the $deps array. If the localisation
* exists, the data array is returned, otherwise false is returned.
+ *
+ * @param string $code
+ * @param array $deps
*/
protected function readSourceFilesAndRegisterDeps( $code, &$deps ) {
global $IP;
wfProfileIn( __METHOD__ );
-
// This reads in the PHP i18n file with non-messages l10n data
$fileName = Language::getMessagesFileName( $code );
if ( !file_exists( $fileName ) ) {
/**
* Merge two localisation values, a primary and a fallback, overwriting the
* primary value in place.
- * @param $key
- * @param $value
- * @param $fallbackValue
+ * @param string $key
+ * @param mixed $value
+ * @param mixed $fallbackValue
*/
protected function mergeItem( $key, &$value, $fallbackValue ) {
if ( !is_null( $value ) ) {
}
/**
- * @param $value
- * @param $fallbackValue
+ * @param mixed $value
+ * @param mixed $fallbackValue
*/
protected function mergeMagicWords( &$value, $fallbackValue ) {
foreach ( $fallbackValue as $magicName => $fallbackInfo ) {
*
* Returns true if any data from the extension array was used, false
* otherwise.
- * @param $codeSequence
- * @param $key
- * @param $value
- * @param $fallbackValue
+ * @param string $codeSequence
+ * @param string $key
+ * @param mixed $value
+ * @param mixed $fallbackValue
* @return bool
*/
protected function mergeExtensionItem( $codeSequence, $key, &$value, $fallbackValue ) {
/**
* Load localisation data for a given language for both core and extensions
* and save it to the persistent cache store and the process cache
- * @param $code
+ * @param string $code
* @throws MWException
*/
public function recache( $code ) {
}
foreach ( $wgExtensionMessagesFiles as $extension => $fileName ) {
+ if ( isset( $wgMessagesDirs[$extension] ) ) {
+ # Already loaded the JSON files for this extension; skip the PHP shim
+ continue;
+ }
+
$data = $this->readPHPFile( $fileName, 'extension' );
$used = false;
foreach ( $data as $key => $item ) {
- if ( $key === 'messages' && isset( $wgMessagesDirs[$extension] ) ) {
- # For backwards compatibility, ignore messages from extensions in
- # $wgExtensionMessagesFiles that are also present in $wgMessagesDirs.
- # This allows extensions to use both and be backwards compatible.
- # Variables other than $messages still need to be supported though.
- continue;
- }
if ( $this->mergeExtensionItem( $codeSequence, $key, $allData[$key], $item ) ) {
$used = true;
}
*
* The preload item will be loaded automatically, improving performance
* for the commonly-requested items it contains.
- * @param $data
+ * @param array $data
* @return array
*/
protected function buildPreload( $data ) {
/**
* Unload the data for a given language from the object cache.
* Reduces memory usage.
- * @param $code
+ * @param string $code
*/
public function unload( $code ) {
unset( $this->data[$code] );
private $maxLoadedLangs = 10;
/**
- * @param $fileName
- * @param $fileType
+ * @param string $fileName
+ * @param string $fileType
* @return array|mixed
*/
protected function readPHPFile( $fileName, $fileType ) {
}
/**
- * @param $code
- * @param $key
+ * @param string $code
+ * @param string $key
* @return mixed
*/
public function getItem( $code, $key ) {
}
/**
- * @param $code
- * @param $key
- * @param $subkey
- * @return
+ * @param string $code
+ * @param string $key
+ * @param string $subkey
+ * @return mixed
*/
public function getSubitem( $code, $key, $subkey ) {
unset( $this->mruLangs[$code] );
}
/**
- * @param $code
+ * @param string $code
*/
public function recache( $code ) {
parent::recache( $code );
}
/**
- * @param $code
+ * @param string $code
*/
public function unload( $code ) {
unset( $this->mruLangs[$code] );