jenkins-bot has submitted this change and it was merged.

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


Migrate to JSON i18n

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

Change-Id: I08de52c2756b477a27e8ba18c79ee87df78a5d3b
---
M php/Parsoid.i18n.php
M php/Parsoid.php
A php/i18n/en.json
A php/i18n/qqq.json
4 files changed, 44 insertions(+), 15 deletions(-)

Approvals:
  Raimond Spekking: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/php/Parsoid.i18n.php b/php/Parsoid.i18n.php
index f972ae3..eeb2776 100644
--- a/php/Parsoid.i18n.php
+++ b/php/Parsoid.i18n.php
@@ -1,15 +1,31 @@
 <?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'] );
+       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 Gabriel Wicke
- */
-$messages['en'] = array(
-       'parsoid-desc' => 'Parsoid wiki runtime for MediaWiki'
-);
-
-/** Message documentation
- */
-$messages['qqq'] = array(
-       'parsoid-desc' => 
'{{desc|name=Parsoid|url=http://www.mediawiki.org/wiki/Parsoid}}',
-);
+               $cachedData['deps'][] = new FileDependency( $fileName );
+       }
+       return true;
+};
diff --git a/php/Parsoid.php b/php/Parsoid.php
index 7609d26..f3e274c 100644
--- a/php/Parsoid.php
+++ b/php/Parsoid.php
@@ -12,7 +12,6 @@
  * Class containing basic setup functions.
  */
 class ParsoidSetup {
-
        /**
         * Set up Parsoid.
         *
@@ -46,12 +45,13 @@
                                'Adam Wight',
                                'C. Scott Ananian'
                        ),
-                       'version' => '0.1.0',
+                       'version' => '0.2.0',
                        'url' => 'https://www.mediawiki.org/wiki/Parsoid',
                        'descriptionmsg' => 'parsoid-desc',
                );
 
                # Register localizations.
+               $wgMessagesDirs['Parsoid'] = __DIR__ . '/i18n';
                $wgExtensionMessagesFiles['Parsoid'] = $dir . 
'/Parsoid.i18n.php';
 
                # Set up a default configuration
@@ -127,7 +127,6 @@
                # File upload
                $wgHooks['FileUpload'][] = 'ParsoidHooks::onFileUpload';
        }
-
 }
 
 # Load hooks that are always set
diff --git a/php/i18n/en.json b/php/i18n/en.json
new file mode 100644
index 0000000..9391dd8
--- /dev/null
+++ b/php/i18n/en.json
@@ -0,0 +1,8 @@
+{
+    "@metadata": {
+        "authors": [
+            "Gabriel Wicke"
+        ]
+    },
+    "parsoid-desc": "Parsoid wiki runtime for MediaWiki"
+}
\ No newline at end of file
diff --git a/php/i18n/qqq.json b/php/i18n/qqq.json
new file mode 100644
index 0000000..bdf9e4a
--- /dev/null
+++ b/php/i18n/qqq.json
@@ -0,0 +1,6 @@
+{
+    "@metadata": {
+        "authors": []
+    },
+    "parsoid-desc": 
"{{desc|name=Parsoid|url=http://www.mediawiki.org/wiki/Parsoid}}";
+}
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I08de52c2756b477a27e8ba18c79ee87df78a5d3b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Raimond Spekking <raimond.spekk...@gmail.com>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to