Nikerabbit has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/103251


Change subject: generateJsonI18n.php: replace i18n.php with a shim
......................................................................

generateJsonI18n.php: replace i18n.php with a shim

Change-Id: I4b8f1d9c0b13fca3aae0bec5c614218e917691ef
---
M maintenance/generateJsonI18n.php
1 file changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/51/103251/1

diff --git a/maintenance/generateJsonI18n.php b/maintenance/generateJsonI18n.php
index f3f8943..4f2febe 100644
--- a/maintenance/generateJsonI18n.php
+++ b/maintenance/generateJsonI18n.php
@@ -90,7 +90,36 @@
                        }
                        $this->output( "$jsonfile\n" );
                }
+
+               $shim = <<<'PHP'
+<?php
+$messages = array();
+$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = function ( $cache, $code, 
&$cachedData ) {
+       $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
+       foreach ( $codeSequence as $csCode ) {
+               $fileName = __DIR__ . "/{{OUT}}/$csCode.json";
+               if ( is_readable( $fileName ) ) {
+                       $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;
+};
+
+PHP;
+
+               $shim = str_replace( '{{OUT}}', $jsondir, $shim );
+               file_put_contents( $phpfile, $shim );
+
                $this->output( "All done.\n" );
+               $this->output( "Also add \$wgMessagesDirs['YourExtension'] = 
__DIR__ . /i18n';\n" );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/103251
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b8f1d9c0b13fca3aae0bec5c614218e917691ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to