Nikerabbit 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: I2db53a18f0bee5eb0745c195890bc9c590788f04
---
M RandomFeaturedUser.i18n.php
M RandomFeaturedUser.php
A i18n/en.json
A i18n/fi.json
A i18n/fr.json
A i18n/nl.json
6 files changed, 71 insertions(+), 44 deletions(-)

Approvals:
  Nikerabbit: Verified; Looks good to me, approved



diff --git a/RandomFeaturedUser.i18n.php b/RandomFeaturedUser.i18n.php
index cb78182..eeb2776 100644
--- a/RandomFeaturedUser.i18n.php
+++ b/RandomFeaturedUser.i18n.php
@@ -1,46 +1,31 @@
 <?php
 /**
- * Internationalization file for the RandomFeaturedUser extension.
+ * This is a backwards-compatibility shim, generated by:
+ * 
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
  *
- * @file
- * @ingroup Extensions
+ * 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 Aaron Wright <[email protected]>
- * @author David Pean <[email protected]>
- */
-$messages['en'] = array(
-       'random-user-points-weekly' => 'points this week',
-       'random-user-points-monthly' => 'points this month',
-       'random-user-about-me' => 'About Me',
-);
-
-/** Finnish (Suomi)
- * @author Jack Phoenix <[email protected]>
- */
-$messages['fi'] = array(
-       'random-user-points-weekly' => 'pistettä tällä viikolla',
-       'random-user-points-monthly' => 'pistettä tässä kuussa',
-       'random-user-about-me' => 'Tietoja minusta',
-);
-
-/** French (Français)
- * @author Jack Phoenix <[email protected]>
- */
-$messages['fr'] = array(
-       'random-user-points-weekly' => 'points cette semaine',
-       'random-user-points-monthly' => 'points points ce mois-ci',
-       'random-user-about-me' => 'À propos de moi',
-);
-
-/** Dutch (Nederlands)
- * @author Mitchel Corstjens
- */
-$messages['nl'] = array(
-       'random-user-points-weekly' => 'punten deze week',
-       'random-user-points-monthly' => 'punten deze month',
-       'random-user-about-me' => 'Over mij',
-);
\ No newline at end of file
+               $cachedData['deps'][] = new FileDependency( $fileName );
+       }
+       return true;
+};
diff --git a/RandomFeaturedUser.php b/RandomFeaturedUser.php
index 22312a7..5313744 100644
--- a/RandomFeaturedUser.php
+++ b/RandomFeaturedUser.php
@@ -13,7 +13,6 @@
  *
  * @file
  * @ingroup Extensions
- * @version 1.1
  * @author Aaron Wright <[email protected]>
  * @author David Pean <[email protected]>
  * @author Jack Phoenix <[email protected]>
@@ -33,14 +32,15 @@
 // Extension credits that will show up on Special:Version
 $wgExtensionCredits['parserhook'][] = array(
        'name' => 'RandomFeaturedUser',
-       'version' => '1.1',
+       'version' => '1.2.0',
        'author' => array( 'Aaron Wright', 'David Pean', 'Jack Phoenix' ),
-       'description' => 'Adds <tt>&lt;randomfeatureduser&gt;</tt> parser hook 
to display a random featured user along with some data',
+       'descriptionmsg' => 'randomfeatureduser-desc',
        'url' => 'https://www.mediawiki.org/wiki/Extension:RandomFeaturedUser',
 );
 
 // Internationalization messages
 $dir = dirname( __FILE__ ) . '/';
+$wgMessagesDirs['RandomFeaturedUser'] = __DIR__ . '/i18n';
 $wgExtensionMessagesFiles['RandomFeaturedUser'] = $dir . 
'RandomFeaturedUser.i18n.php';
 
 $wgHooks['ParserFirstCallInit'][] = 'wfRandomFeaturedUser';
@@ -168,4 +168,4 @@
        wfProfileOut( __METHOD__ );
 
        return $output;
-}
\ No newline at end of file
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..d3c092b
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,12 @@
+{
+    "@metadata": {
+        "authors": [
+            "Aaron Wright <[email protected]>",
+            "David Pean <[email protected]>"
+        ]
+    },
+    "randomfeatureduser-desc": "Adds <code>&lt;randomfeatureduser&gt;</code> 
parser hook to display a random featured user along with some data",
+    "random-user-points-weekly": "points this week",
+    "random-user-points-monthly": "points this month",
+    "random-user-about-me": "About Me"
+}
diff --git a/i18n/fi.json b/i18n/fi.json
new file mode 100644
index 0000000..be4d670
--- /dev/null
+++ b/i18n/fi.json
@@ -0,0 +1,10 @@
+{
+    "@metadata": {
+        "authors": [
+            "Jack Phoenix <[email protected]>"
+        ]
+    },
+    "random-user-points-weekly": "pistettä tällä viikolla",
+    "random-user-points-monthly": "pistettä tässä kuussa",
+    "random-user-about-me": "Tietoja minusta"
+}
diff --git a/i18n/fr.json b/i18n/fr.json
new file mode 100644
index 0000000..b3b5457
--- /dev/null
+++ b/i18n/fr.json
@@ -0,0 +1,10 @@
+{
+    "@metadata": {
+        "authors": [
+            "Jack Phoenix <[email protected]>"
+        ]
+    },
+    "random-user-points-weekly": "points cette semaine",
+    "random-user-points-monthly": "points points ce mois-ci",
+    "random-user-about-me": "À propos de moi"
+}
diff --git a/i18n/nl.json b/i18n/nl.json
new file mode 100644
index 0000000..4472435
--- /dev/null
+++ b/i18n/nl.json
@@ -0,0 +1,10 @@
+{
+    "@metadata": {
+        "authors": [
+            "Mitchel Corstjens"
+        ]
+    },
+    "random-user-points-weekly": "punten deze week",
+    "random-user-points-monthly": "punten deze month",
+    "random-user-about-me": "Over mij"
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2db53a18f0bee5eb0745c195890bc9c590788f04
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RandomFeaturedUser
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>

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

Reply via email to