From 2d01b8be9f3a14255b802ab59d0b9e4872245568 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sun, 22 Dec 2013 17:11:14 +0000 Subject: [PATCH] generateJsonI18n.php: replace i18n.php with a shim Change-Id: I4b8f1d9c0b13fca3aae0bec5c614218e917691ef --- maintenance/generateJsonI18n.php | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/maintenance/generateJsonI18n.php b/maintenance/generateJsonI18n.php index f3f89437ae..554e0a848e 100644 --- a/maintenance/generateJsonI18n.php +++ b/maintenance/generateJsonI18n.php @@ -90,7 +90,44 @@ class GenerateJsonI18n extends Maintenance { } $this->output( "$jsonfile\n" ); } + + if ( !$this->hasOption( 'langcode' ) ) { + $shim = $this->doShim( $jsondir ); + file_put_contents( $phpfile, $shim ); + } + $this->output( "All done.\n" ); + $this->output( "Also add \$wgMessagesDirs['YourExtension'] = __DIR__ . /i18n';\n" ); + } + + protected function doShim( $jsondir ) { + $shim = <<<'PHP' + $unused ) { + if ( $key === '' || $key[0] === '@' ) { + unset( $data[$key] ); + } + } + $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); + } + + $cachedData['deps'][] = new FileDependency( $fileName ); + } + return true; +}; + +PHP; + + $jsondir = str_replace('\\', '/', $jsondir ); + $shim = str_replace( '{{OUT}}', $jsondir, $shim ); + return $shim; } /** -- 2.20.1