mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
880a972166
Replace VisualEditor.i18n.php with a shim that uses the LocalisationCacheRecache hook to read messages from JSON files and add cache dependencies. Change-Id: Ib8490d3e327ddf5852827c24ee2aa2916c8af072
24 lines
779 B
PHP
24 lines
779 B
PHP
<?php
|
|
$messages = array();
|
|
$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = function ( $cache, $code, &$cachedData ) {
|
|
global $wgMessagesDirs;
|
|
$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] );
|
|
foreach ( (array)$wgMessagesDirs['VisualEditor'] as $dir ) {
|
|
foreach ( $codeSequence as $csCode ) {
|
|
$fileName = "$dir/$csCode.json";
|
|
if ( !is_readable( $fileName ) ) {
|
|
continue;
|
|
}
|
|
$data = FormatJson::decode( file_get_contents( $fileName ), true );
|
|
foreach ( $data as $key => $unused ) {
|
|
if ( $key === '' || $key[0] === '@' ) {
|
|
unset( $data[$key] );
|
|
}
|
|
}
|
|
$cachedData['messages'] = array_merge( $data, $cachedData['messages'] );
|
|
$cachedData['deps'][] = new FileDependency( $fileName );
|
|
}
|
|
}
|
|
return true;
|
|
};
|