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: I0e746136b5b17eceab96c269d0de643247b399c7
---
M ViewFiles.i18n.php
M ViewFiles.php
A i18n/en.json
A i18n/qqq.json
4 files changed, 48 insertions(+), 24 deletions(-)

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



diff --git a/ViewFiles.i18n.php b/ViewFiles.i18n.php
index 15112b5..eeb2776 100644
--- a/ViewFiles.i18n.php
+++ b/ViewFiles.i18n.php
@@ -1,29 +1,31 @@
 <?php
 /**
- * Internationalisation for ViewFiles
+ * 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 Leucosticte
- */
-$messages['en'] = array(
-       'viewfiles' => 'View files',
-       'viewfiles-desc' => 'Adds a [[Special:ViewFiles|special page]] to view 
the current contents of a limited set of files',
-       'viewfiles-no-files-available' => 'No files have been made available 
for viewing.',
-       'viewfiles-no-geshi' => 'Error: You need to download and install the 
[https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi GeSHi 
SyntaxHighlight extension].
-Be sure to add both these lines to your LocalSettings.php file:',
-);
-
-/** Message documentation
- * @author Leucosticte
- */
-$messages['qqq'] = array(
-       'viewfiles-desc' => '{{desc}}',
-       'viewfiles-no-files-available' => 'This is the message the user gets if 
no files have been made available by the system administrator for viewing.',
-       'viewfiles-no-geshi' => 'This is the message the user gets if the 
SyntaxHighlight GeSHi extension, upon which the ViewFiles extension depends, 
has not been installed properly.
-Following this message, the two require_once lines that the system 
administrator needs to add to LocalSettings.php are displayed.',
-);
+               $cachedData['deps'][] = new FileDependency( $fileName );
+       }
+       return true;
+};
diff --git a/ViewFiles.php b/ViewFiles.php
index b2be4d1..42b63aa 100644
--- a/ViewFiles.php
+++ b/ViewFiles.php
@@ -38,10 +38,11 @@
        'author' => '[https://www.mediawiki.org/wiki/User:Leucosticte 
Leucosticte]',
        'url' => 'https://www.mediawiki.org/wiki/Extension:ViewFiles',
        'descriptionmsg' => 'viewfiles-desc',
-       'version' => '1.0.3',
+       'version' => '1.1.0',
 );
 
 $wgAutoloadClasses['SpecialViewFiles'] = __DIR__ . '/SpecialViewFiles.php';
+$wgMessagesDirs['ViewFiles'] = __DIR__ . '/i18n';
 $wgExtensionMessagesFiles['ViewFiles'] = __DIR__ . '/ViewFiles.i18n.php';
 $wgExtensionMessagesFiles['ViewFilesAlias'] = __DIR__ . '/ViewFiles.alias.php';
 $wgSpecialPages['ViewFiles'] = 'SpecialViewFiles';
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..d3bd34c
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,11 @@
+{
+    "@metadata": {
+        "authors": [
+            "Leucosticte"
+        ]
+    },
+    "viewfiles": "View files",
+    "viewfiles-desc": "Adds a [[Special:ViewFiles|special page]] to view the 
current contents of a limited set of files",
+    "viewfiles-no-files-available": "No files have been made available for 
viewing.",
+    "viewfiles-no-geshi": "Error: You need to download and install the 
[https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi GeSHi 
SyntaxHighlight extension].\nBe sure to add both these lines to your 
LocalSettings.php file:"
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..c6157ee
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,10 @@
+{
+    "@metadata": {
+        "authors": [
+            "Leucosticte"
+        ]
+    },
+    "viewfiles-desc": "{{desc}}",
+    "viewfiles-no-files-available": "This is the message the user gets if no 
files have been made available by the system administrator for viewing.",
+    "viewfiles-no-geshi": "This is the message the user gets if the 
SyntaxHighlight GeSHi extension, upon which the ViewFiles extension depends, 
has not been installed properly.\nFollowing this message, the two require_once 
lines that the system administrator needs to add to LocalSettings.php are 
displayed."
+}

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

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

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

Reply via email to