Commafy support for convertNumber
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderLanguageDataModule.php
index a36aaec..0f8e54c 100644 (file)
@@ -28,8 +28,9 @@
 class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
 
        protected $language;
+       protected $targets = array( 'desktop', 'mobile' );
        /**
-        * Get the grammer forms for the site content language.
+        * Get the grammar forms for the site content language.
         *
         * @return array
         */
@@ -37,41 +38,65 @@ class ResourceLoaderLanguageDataModule extends ResourceLoaderModule {
                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
-        * Seperator transform table also required here to convert
-        * the . and , sign to appropriate forms in content language.
         *
         * @return array
         */
        protected function getDigitTransformTable() {
-               $digitTransformTable = $this->language->digitTransformTable();
-               $separatorTransformTable = $this->language->separatorTransformTable();
-               if ( $digitTransformTable ) {
-                       array_merge( $digitTransformTable, (array)$separatorTransformTable );
-               } else {
-                       return $separatorTransformTable;
-               }
-               return $digitTransformTable;
+               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
         *
         * @return array
         */
        protected function getData() {
-               return array( 'grammarForms' => $this->getSiteLangGrammarForms(),
-                               'digitTransformTable' => $this->getDigitTransformTable()
-                       );
+               return array(
+                       'digitTransformTable' => $this->getDigitTransformTable(),
+                       'separatorTransformTable' => $this->getSeparatorTransformTable(),
+                       'grammarForms' => $this->getSiteLangGrammarForms(),
+                       'pluralRules' => $this->getPluralRules(),
+                       'digitGroupingPattern' => $this->getDigitGroupingPattern(),
+               );
        }
 
        /**
         * @param $context ResourceLoaderContext
-        * @return string: Javascript code
+        * @return string: JavaScript code
         */
        public function getScript( ResourceLoaderContext $context ) {
-               $this->language = Language::factory( $context ->getLanguage() );
+               $this->language = Language::factory( $context->getLanguage() );
                return Xml::encodeJsCall( 'mw.language.setData', array(
                        $this->language->getCode(),
                        $this->getData()