$jsonfile = "$jsondir/$langcode.json";
$success = file_put_contents(
$jsonfile,
- FormatJson::encode( $langmsgs, true, FormatJson::ALL_OK )
+ FormatJson::encode( $langmsgs, true, FormatJson::ALL_OK ) . "\n"
);
if ( $success === false ) {
$this->error( "FAILED to write $jsonfile", 1 );
protected function doShim( $jsondir ) {
$shim = <<<'PHP'
<?php
+/**
+ * This is a backwards-compatibility shim, generated by:
+ * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
+ *
+ * Beginning with MediaWiki 1.23, translation strings are stored in json files,
+ * and the EXTENSION.i18n.php file only exists to provide compatibility with
+ * older releases of MediaWiki. For more information about this migration, see:
+ * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
+ *
+ * This shim maintains compatibility back to MediaWiki 1.17.
+ */
$messages = array();
$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = function ( $cache, $code, &$cachedData ) {
$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] );
PHP;
- $jsondir = str_replace('\\', '/', $jsondir );
+ $jsondir = str_replace( '\\', '/', $jsondir );
$shim = str_replace( '{{OUT}}', $jsondir, $shim );
return $shim;
}