mediawiki-extensions-Visual.../VisualEditor.i18n.php

24 lines
779 B
PHP
Raw Normal View History

2011-11-28 20:28:28 +00:00
<?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;
};