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