MediaWiki REL1_31
LocalisationUpdate.php
Go to the documentation of this file.
1<?php
2
14 public static function onRecacheFallback( LocalisationCache $lc, $code, array &$cache ) {
15 $dir = self::getDirectory();
16 if ( !$dir ) {
17 return true;
18 }
19
20 $fileName = "$dir/" . self::getFilename( $code );
21 if ( is_readable( $fileName ) ) {
22 $data = FormatJson::decode( file_get_contents( $fileName ), true );
23 $cache['messages'] = array_merge( $cache['messages'], $data );
24 }
25
26 return true;
27 }
28
36 public static function onRecache( LocalisationCache $lc, $code, array &$cache ) {
37 $dir = self::getDirectory();
38 if ( !$dir ) {
39 return true;
40 }
41
42 $codeSequence = array_merge( [ $code ], $cache['fallbackSequence'] );
43 foreach ( $codeSequence as $csCode ) {
44 $fileName = "$dir/" . self::getFilename( $csCode );
45 $cache['deps'][] = new FileDependency( $fileName );
46 }
47
48 return true;
49 }
50
57 public static function getDirectory() {
58 global $wgLocalisationUpdateDirectory, $wgCacheDirectory;
59
60 return $wgLocalisationUpdateDirectory ?: $wgCacheDirectory;
61 }
62
70 public static function getFilename( $language ) {
71 return "l10nupdate-$language.json";
72 }
73}
$wgCacheDirectory
Directory for caching data in the local filesystem.
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
static getDirectory()
Returns a directory where updated translations are stored.
static onRecache(LocalisationCache $lc, $code, array &$cache)
Hook: LocalisationCacheRecache.
static onRecacheFallback(LocalisationCache $lc, $code, array &$cache)
Hook: LocalisationCacheRecacheFallback.
static getFilename( $language)
Returns a filename where updated translations are stored.
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
Definition hooks.txt:865
$cache
Definition mcc.php:33