MediaWiki REL1_30
LocalisationUpdate.class.php
Go to the documentation of this file.
1<?php
2
10 public static function onRecacheFallback( LocalisationCache $lc, $code, array &$cache ) {
11 $dir = self::getDirectory();
12 if ( !$dir ) {
13 return true;
14 }
15
16 $fileName = "$dir/" . self::getFilename( $code );
17 if ( is_readable( $fileName ) ) {
18 $data = FormatJson::decode( file_get_contents( $fileName ), true );
19 $cache['messages'] = array_merge( $cache['messages'], $data );
20 }
21
22 return true;
23 }
24
28 public static function onRecache( LocalisationCache $lc, $code, array &$cache ) {
29 $dir = self::getDirectory();
30 if ( !$dir ) {
31 return true;
32 }
33
34 $codeSequence = array_merge( [ $code ], $cache['fallbackSequence'] );
35 foreach ( $codeSequence as $csCode ) {
36 $fileName = "$dir/" . self::getFilename( $csCode );
37 $cache['deps'][] = new FileDependency( $fileName );
38 }
39
40 return true;
41 }
42
49 public static function getDirectory() {
50 global $wgLocalisationUpdateDirectory, $wgCacheDirectory;
51
52 return $wgLocalisationUpdateDirectory ?: $wgCacheDirectory;
53 }
54
62 public static function getFilename( $language ) {
63 return "l10nupdate-$language.json";
64 }
65}
$dir
Definition Autoload.php:8
$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:863
$cache
Definition mcc.php:33