Make grammar data loadable as an RL module and usable in JS
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderLanguageDataModule.php
index be15008..ef942fa 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Resource loader module for populating language specific data.
+ * ResourceLoader module for populating language specific data.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
  */
 class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
 
-       protected $targets = array( 'desktop', 'mobile' );
+       protected $targets = [ 'desktop', 'mobile' ];
 
        /**
         * Get all the dynamic data for the content language to an array.
@@ -37,14 +37,15 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
         */
        protected function getData( ResourceLoaderContext $context ) {
                $language = Language::factory( $context->getLanguage() );
-               return array(
+               return [
                        'digitTransformTable' => $language->digitTransformTable(),
                        'separatorTransformTable' => $language->separatorTransformTable(),
                        'grammarForms' => $language->getGrammarForms(),
+                       'grammarTransformations' => $language->getGrammarTransformations(),
                        'pluralRules' => $language->getPluralRules(),
                        'digitGroupingPattern' => $language->digitGroupingPattern(),
                        'fallbackLanguages' => $language->getFallbackLanguages(),
-               );
+               ];
        }
 
        /**
@@ -54,20 +55,19 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
        public function getScript( ResourceLoaderContext $context ) {
                return Xml::encodeJsCall(
                        'mw.language.setData',
-                       array(
+                       [
                                $context->getLanguage(),
                                $this->getData( $context )
-                       ),
+                       ],
                        ResourceLoader::inDebugMode()
                );
        }
 
        /**
-        * @param ResourceLoaderContext $context
-        * @return string Hash
+        * @return bool
         */
-       public function getModifiedHash( ResourceLoaderContext $context ) {
-               return md5( serialize( $this->getData( $context ) ) );
+       public function enableModuleContentVersion() {
+               return true;
        }
 
        /**
@@ -75,6 +75,6 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
         * @return array
         */
        public function getDependencies( ResourceLoaderContext $context = null ) {
-               return array( 'mediawiki.language.init' );
+               return [ 'mediawiki.language.init' ];
        }
 }