Merge "Converted Interwiki using WAN cache"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderLanguageDataModule.php
index 77dcdf9..1239453 100644 (file)
  */
 class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
 
-       protected $language;
        protected $targets = array( 'desktop', 'mobile' );
-       /**
-        * Get the grammar forms for the site content language.
-        *
-        * @return array
-        */
-       protected function getSiteLangGrammarForms() {
-               return $this->language->getGrammarForms();
-       }
-
-       /**
-        * Get the plural forms for the site content language.
-        *
-        * @return array
-        */
-       protected function getPluralRules() {
-               return $this->language->getPluralRules();
-       }
-
-       /**
-        * Get the digit groupin Pattern for the site content language.
-        *
-        * @return array
-        */
-       protected function getDigitGroupingPattern() {
-               return $this->language->digitGroupingPattern();
-       }
-
-       /**
-        * Get the digit transform table for the content language
-        *
-        * @return array
-        */
-       protected function getDigitTransformTable() {
-               return $this->language->digitTransformTable();
-       }
-
-       /**
-        * Get seperator transform table required for converting
-        * the . and , sign to appropriate forms in site content language.
-        *
-        * @return array
-        */
-       protected function getSeparatorTransformTable() {
-               return $this->language->separatorTransformTable();
-       }
 
        /**
         * Get all the dynamic data for the content language to an array.
         *
-        * NOTE: Before calling this you HAVE to make sure $this->language is set.
-        *
+        * @param ResourceLoaderContext $context
         * @return array
         */
-       protected function getData() {
+       protected function getData( ResourceLoaderContext $context ) {
+               $language = Language::factory( $context->getLanguage() );
                return array(
-                       'digitTransformTable' => $this->getDigitTransformTable(),
-                       'separatorTransformTable' => $this->getSeparatorTransformTable(),
-                       'grammarForms' => $this->getSiteLangGrammarForms(),
-                       'pluralRules' => $this->getPluralRules(),
-                       'digitGroupingPattern' => $this->getDigitGroupingPattern(),
+                       'digitTransformTable' => $language->digitTransformTable(),
+                       'separatorTransformTable' => $language->separatorTransformTable(),
+                       'grammarForms' => $language->getGrammarForms(),
+                       'pluralRules' => $language->getPluralRules(),
+                       'digitGroupingPattern' => $language->digitGroupingPattern(),
+                       'fallbackLanguages' => $language->getFallbackLanguages(),
                );
        }
 
@@ -97,11 +52,14 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
         * @return string JavaScript code
         */
        public function getScript( ResourceLoaderContext $context ) {
-               $this->language = Language::factory( $context->getLanguage() );
-               return Xml::encodeJsCall( 'mw.language.setData', array(
-                       $this->language->getCode(),
-                       $this->getData()
-               ) );
+               return Xml::encodeJsCall(
+                       'mw.language.setData',
+                       array(
+                               $context->getLanguage(),
+                               $this->getData( $context )
+                       ),
+                       ResourceLoader::inDebugMode()
+               );
        }
 
        /**
@@ -117,9 +75,7 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
         * @return string Hash
         */
        public function getModifiedHash( ResourceLoaderContext $context ) {
-               $this->language = Language::factory( $context->getLanguage() );
-
-               return md5( serialize( $this->getData() ) );
+               return md5( serialize( $this->getData( $context ) ) );
        }
 
        /**