mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
789d187ce5
Apparently the .i18n.php shim is causing problems in both production and beta labs, so for now we'll just generate the .i18n.php file from the JSON files. The first half of the conversion script is identical to the shim. Change-Id: Id606584197d7efcff6fff29ea22cd35dd744b55e
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
$messages = array();
|
|
array_map( function ( $dir ) use ( &$messages ) {
|
|
$files = glob( __DIR__ . "/../$dir/*.json" );
|
|
foreach ( $files as $file ) {
|
|
$langcode = substr( basename( $file ), 0, -5 );
|
|
$data = json_decode( file_get_contents( $file ), /* $assoc = */ true );
|
|
unset( $data['@metadata'] );
|
|
$messages[$langcode] = isset( $messages[$langcode] ) ?
|
|
array_merge( $messages[$langcode], $data ) :
|
|
$data;
|
|
}
|
|
}, array(
|
|
'modules/oojs-ui/i18n',
|
|
'modules/ve/i18n',
|
|
'modules/ve-mw/i18n',
|
|
'modules/ve-wmf/i18n'
|
|
) );
|
|
|
|
$output = <<<END
|
|
<?php
|
|
/**
|
|
* DO NOT EDIT THIS FILE
|
|
*
|
|
* This file is GENERATED from the JSON blobs in the i18n directories, where the actual i18n
|
|
* messages live.
|
|
*
|
|
* DO NOT EDIT THIS FILE
|
|
*
|
|
* Instead, make your changes in modules/.../i18n/en.json and qqq.json, then run
|
|
* php bin/buildi18n-php.php to rebuild this file.
|
|
*
|
|
* NO SERIOUSLY, DO NOT DIRECTLY EDIT THIS FILE, EVER
|
|
* @file
|
|
*/
|
|
\$messages = array();
|
|
|
|
END;
|
|
$firstcodes = array( 'en', 'qqq' );
|
|
$langcodes = array_merge( $firstcodes, array_diff( array_keys( $messages ), $firstcodes ) );
|
|
foreach ( $langcodes as $langcode ) {
|
|
$output .= "\n\$messages['$langcode'] = " . var_export( $messages[$langcode], true ) . ";\n";
|
|
}
|
|
|
|
file_put_contents( __DIR__ . '/../VisualEditor.i18n.php', $output );
|