Siebrand has uploaded a new change for review. https://gerrit.wikimedia.org/r/123580
Change subject: Migrate to JSON i18n ...................................................................... Migrate to JSON i18n Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php with shim. Change-Id: I9867eeb7eba23b6f0cb414d16b0200b2d9e12103 --- M JsonData.i18n.php M JsonData.php A i18n/en.json 3 files changed, 58 insertions(+), 39 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/JsonData refs/changes/80/123580/1 diff --git a/JsonData.i18n.php b/JsonData.i18n.php index 8c3589c..eeb2776 100644 --- a/JsonData.i18n.php +++ b/JsonData.i18n.php @@ -1,33 +1,31 @@ <?php /** - * Internationalisation file for the JsonData extension. + * This is a backwards-compatibility shim, generated by: + * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php * - * @file JsonData.i18n.php - * @ingroup Extensions - * @author Rob Lanphier - * @copyright © 2011-2012 Rob Lanphier - * @license GNU General Public Licence 2.0 or later + * 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'] ); + foreach ( $codeSequence as $csCode ) { + $fileName = __DIR__ . "/i18n/$csCode.json"; + if ( is_readable( $fileName ) ) { + $data = FormatJson::decode( file_get_contents( $fileName ), true ); + foreach ( array_keys( $data ) as $key ) { + if ( $key === '' || $key[0] === '@' ) { + unset( $data[$key] ); + } + } + $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); + } -/** English - * @author Rob Lanphier - */ -$messages['en'] = array( - 'jsondata' => 'JsonData', - 'jsondata-desc' => 'An extension to edit and template JSON-formatted data', - 'jsondata-schemaedit-pref' => 'Use JsonData schema editing tools', - 'prefs-jsondata' => 'JsonData', - 'jsondata-servervalidationerror' => 'Server validation error', - 'jsondata-invalidjson' => 'Invalid JSON', - 'jsondata-server-error' => 'Server error', - 'jsondata-true' => 'true', - 'jsondata-false' => 'false', - 'jsonschema-badidref' => 'Bad idref: "$1"', - 'jsonschema-idconvert' => 'Cannot convert var to id: "$1"', - 'jsonschema-invalidkey' => 'Invalid key "$1" in "$2"', - 'jsonschema-invalidempty' => 'Empty data structure not valid with this schema', - 'jsonschema-invalidnode' => 'Invalid node: expecting "$1", got "$2". Path: "$3"', -); - + $cachedData['deps'][] = new FileDependency( $fileName ); + } + return true; +}; diff --git a/JsonData.php b/JsonData.php index fdf82ae..0b44c8e 100644 --- a/JsonData.php +++ b/JsonData.php @@ -19,11 +19,12 @@ 'url' => 'https://www.mediawiki.org/wiki/Extension:JsonData', ); -$wgExtensionMessagesFiles['JsonData'] = dirname( __FILE__ ) . '/JsonData.i18n.php'; -$wgAutoloadClasses['JsonDataHooks'] = dirname( __FILE__ ) . '/JsonData.hooks.php'; -$wgAutoloadClasses['JsonData'] = dirname( __FILE__ ) . '/JsonData_body.php'; -$wgAutoloadClasses['JsonTreeRef'] = dirname( __FILE__ ) . '/JsonSchema.php'; -$wgAutoloadClasses['JsonDataMarkup'] = dirname( __FILE__ ) . '/JsonDataMarkup.php'; +$wgMessagesDirs['JsonData'] = __DIR__ . '/i18n'; +$wgExtensionMessagesFiles['JsonData'] = __DIR__ . '/JsonData.i18n.php'; +$wgAutoloadClasses['JsonDataHooks'] = __DIR__ . '/JsonData.hooks.php'; +$wgAutoloadClasses['JsonData'] = __DIR__ . '/JsonData_body.php'; +$wgAutoloadClasses['JsonTreeRef'] = __DIR__ . '/JsonSchema.php'; +$wgAutoloadClasses['JsonDataMarkup'] = __DIR__ . '/JsonDataMarkup.php'; $wgHooks['BeforePageDisplay'][] = 'JsonDataHooks::beforePageDisplay'; $wgHooks['EditPage::showEditForm:fields'][] = 'JsonDataHooks::onEditPageShowEditFormInitial'; @@ -45,11 +46,11 @@ // $wgJsonDataPredefinedData = array(); -$wgJsonDataPredefinedData['openschema'] = dirname( __FILE__ ) . "/schemas/openschema.json"; -$wgJsonDataPredefinedData['schemaschema'] = dirname( __FILE__ ) . "/schemas/schemaschema.json"; -$wgJsonDataPredefinedData['configexample'] = dirname( __FILE__ ) . "/example/configexample.json"; -$wgJsonDataPredefinedData['configschema'] = dirname( __FILE__ ) . "/schemas/jsondata-config-schema.json"; -$wgJsonDataPredefinedData['simpleaddr'] = dirname( __FILE__ ) . "/schemas/simpleaddr-schema.json"; +$wgJsonDataPredefinedData['openschema'] = __DIR__ . "/schemas/openschema.json"; +$wgJsonDataPredefinedData['schemaschema'] = __DIR__ . "/schemas/schemaschema.json"; +$wgJsonDataPredefinedData['configexample'] = __DIR__ . "/example/configexample.json"; +$wgJsonDataPredefinedData['configschema'] = __DIR__ . "/schemas/jsondata-config-schema.json"; +$wgJsonDataPredefinedData['simpleaddr'] = __DIR__ . "/schemas/simpleaddr-schema.json"; $wgJsonDataConfig = array( 'srctype' => 'predefined', 'src' => 'configexample' ); @@ -63,11 +64,10 @@ 'mw.jsondata.css', 'jsonwidget.css' ), - 'localBasePath' => dirname( __FILE__ ) . '/resources', + 'localBasePath' => __DIR__ . '/resources', 'remoteExtPath' => 'JsonData/resources' ); $wgHooks['GetPreferences'][] = 'JsonDataHooks::onGetPreferences'; $wgHooks['EditFilter'][] = 'JsonDataHooks::validateDataEditFilter'; - diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..2024042 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,21 @@ +{ + "@metadata": { + "authors": [ + "Rob Lanphier" + ] + }, + "jsondata": "JsonData", + "jsondata-desc": "An extension to edit and template JSON-formatted data", + "jsondata-schemaedit-pref": "Use JsonData schema editing tools", + "prefs-jsondata": "JsonData", + "jsondata-servervalidationerror": "Server validation error", + "jsondata-invalidjson": "Invalid JSON", + "jsondata-server-error": "Server error", + "jsondata-true": "true", + "jsondata-false": "false", + "jsonschema-badidref": "Bad idref: \"$1\"", + "jsonschema-idconvert": "Cannot convert var to id: \"$1\"", + "jsonschema-invalidkey": "Invalid key \"$1\" in \"$2\"", + "jsonschema-invalidempty": "Empty data structure not valid with this schema", + "jsonschema-invalidnode": "Invalid node: expecting \"$1\", got \"$2\". Path: \"$3\"" +} -- To view, visit https://gerrit.wikimedia.org/r/123580 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9867eeb7eba23b6f0cb414d16b0200b2d9e12103 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/JsonData Gerrit-Branch: master Gerrit-Owner: Siebrand <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
