Siebrand has uploaded a new change for review.

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

Change subject: Migrate to JSON i18n
......................................................................

Migrate to JSON i18n

Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php
with shim.

Change-Id: Icfaef3a3bd3428c622f381637444298cce42507a
---
M MoodleWS.i18n.php
M MoodleWS.php
A i18n/en.json
A i18n/qqq.json
4 files changed, 44 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Moodle 
refs/changes/81/123581/1

diff --git a/MoodleWS.i18n.php b/MoodleWS.i18n.php
index d276cc6..eeb2776 100644
--- a/MoodleWS.i18n.php
+++ b/MoodleWS.i18n.php
@@ -1,7 +1,31 @@
 <?php
-$messages['en'] = array(
-  'uploadwizard-desc' => 'Upload Wizard, a user-friendly tool for uploading 
multimedia'
-);
-$messages['qqq'] = array(
-  'uploadwizard-desc' => 'Description of extension. It refers to 
[//blog.wikimedia.org/blog/2009/07/02/ford-foundation-awards-300k-grant-for-wikimedia-commons/
 this event], i.e. the development was paid with this $300,000 grant.'
-);
+/**
+ * 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'] );
+       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;
+};
diff --git a/MoodleWS.php b/MoodleWS.php
index e14a076..909eb70 100644
--- a/MoodleWS.php
+++ b/MoodleWS.php
@@ -9,6 +9,7 @@
 $wgAutoloadClasses['MoodleWS'] = __DIR__ . '/MoodleWS.body.php';
 $wgAutoloadClasses[ 'SpecialMoodleWS' ] = __DIR__ . '/SpecialMoodleWS.php'; # 
Location of the SpecialMoodleWS class (Tell MediaWiki to load this file)
 
+$wgMessagesDirs['MoodleWS'] = __DIR__ . '/i18n';
 $wgExtensionMessagesFiles[ 'MoodleWS' ] = __DIR__ . '/MoodleWS.i18n.php'; # 
Location of a messages file (Tell MediaWiki to load this file)
 
 $wgExtensionMessagesFiles[ 'MoodleWSAlias' ] = __DIR__ . 
'/MoodleWS.alias.php'; # Location of an aliases file (Tell MediaWiki to load 
this file)
@@ -39,7 +40,7 @@
        'author' => 'Clancer',
        'url' => 'https://www.mediawiki.org/wiki/Extension:Moodle',
        'description' => 'Moodle integration',
-       'version'  => 0.1,
+       'version'  => '0.2.0',
        );
 
 $wgHooks['ParserFirstCallInit'][] = 'wfSampleParserInit';
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..cd8d2cc
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,6 @@
+{
+    "@metadata": {
+        "authors": []
+    },
+    "uploadwizard-desc": "Upload Wizard, a user-friendly tool for uploading 
multimedia"
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..f860def
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,6 @@
+{
+    "@metadata": {
+        "authors": []
+    },
+    "uploadwizard-desc": "Description of extension. It refers to 
[//blog.wikimedia.org/blog/2009/07/02/ford-foundation-awards-300k-grant-for-wikimedia-commons/
 this event], i.e. the development was paid with this $300,000 grant."
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfaef3a3bd3428c622f381637444298cce42507a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Moodle
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>

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

Reply via email to