Siebrand has uploaded a new change for review. https://gerrit.wikimedia.org/r/123591
Change subject: Migrate to JSON i18n ...................................................................... Migrate to JSON i18n Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php with shim. Change-Id: I994098a1496fd4e69a5d1db9836028d6e9218d8b --- M SemanticImageAnnotator.php A i18n/de.json A i18n/en.json M languages/SIA_Messages.php 4 files changed, 52 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticImageAnnotator refs/changes/91/123591/1 diff --git a/SemanticImageAnnotator.php b/SemanticImageAnnotator.php index 456fe99..ef6dd74 100644 --- a/SemanticImageAnnotator.php +++ b/SemanticImageAnnotator.php @@ -17,14 +17,14 @@ $wgExtensionCredits['semantic'][] = array( 'path' => __FILE__, 'name' => 'Semantic Image Annotator', - 'version' => '0.5', + 'version' => '0.6.0', 'author' => 'Felix Obenauer', 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Image_Annotator', 'descriptionmsg' => 'sia-description', ); -$dir = dirname(__FILE__); -$wgExtensionMessagesFiles['SemanticImageAnnotator'] = "$dir/languages/SIA_Messages.php"; +$wgMessagesDirs['SemanticImageAnnotator'] = __DIR__ . '/i18n'; +$wgExtensionMessagesFiles['SemanticImageAnnotator'] = __DIR__ . "/languages/SIA_Messages.php"; include_once('SIA_AjaxFunctions.php'); diff --git a/i18n/de.json b/i18n/de.json new file mode 100644 index 0000000..39234da --- /dev/null +++ b/i18n/de.json @@ -0,0 +1,11 @@ +{ + "@metadata": { + "authors": [ + "Felix Obenauer" + ] + }, + "sia-description": "Füge Bildern semantische Annotationen hinzu und frage diese ab", + "sia-comment": "Kommentar", + "sia-buttonannotate": "Dieses Bild annotieren", + "sia-resize": "Bildgröße ändern" +} diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..eb08864 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,11 @@ +{ + "@metadata": { + "authors": [ + "Felix Obenauer" + ] + }, + "sia-description": "Semantically annotate images and query for annotations", + "sia-comment": "comment", + "sia-buttonannotate": "Annotate this image", + "sia-resize": "Resize image" +} diff --git a/languages/SIA_Messages.php b/languages/SIA_Messages.php index 608e0f1..fc65d35 100644 --- a/languages/SIA_Messages.php +++ b/languages/SIA_Messages.php @@ -1,25 +1,31 @@ <?php /** - * Internationalization file for Semantic Image Annotator + * 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(); - /** - * English - * @author Felix Obenauer - */ -$messages['en'] = array( - 'sia-description' => 'Semantically annotate images and query for annotations', - 'sia-comment' => 'comment', - 'sia-buttonannotate'=> 'Annotate this image', - 'sia-resize' => 'Resize image' -); - /** - * German - * @author Felix Obenauer - */ -$messages['de'] = array( - 'sia-description' => 'Füge Bildern semantische Annotationen hinzu und frage diese ab', - 'sia-comment' => 'Kommentar', - 'sia-buttonannotate'=> 'Dieses Bild annotieren', - 'sia-resize' => 'Bildgröße ändern' -); +$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'] ); + } + + $cachedData['deps'][] = new FileDependency( $fileName ); + } + return true; +}; -- To view, visit https://gerrit.wikimedia.org/r/123591 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I994098a1496fd4e69a5d1db9836028d6e9218d8b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticImageAnnotator Gerrit-Branch: master Gerrit-Owner: Siebrand <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
