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 * * @return array */ protected function getData() { return array( 'digitTransformTable' => $this->getDigitTransformTable(), 'separatorTransformTable' => $this->getSeparatorTransformTable(), 'grammarForms' => $this->getSiteLangGrammarForms(), 'pluralRules' => $this->getPluralRules(), 'digitGroupingPattern' => $this->getDigitGroupingPattern(), ); } /** * @param $context ResourceLoaderContext * @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() ) ); } /** * @param $context ResourceLoaderContext * @return array|int|Mixed */ public function getModifiedTime( ResourceLoaderContext $context ) { $this->language = Language::factory( $context ->getLanguage() ); $cache = wfGetCache( CACHE_ANYTHING ); $key = wfMemcKey( 'resourceloader', 'langdatamodule', 'changeinfo' ); $data = $this->getData(); $hash = md5( serialize( $data ) ); $result = $cache->get( $key ); if ( is_array( $result ) && $result['hash'] === $hash ) { return $result['timestamp']; } $timestamp = wfTimestamp(); $cache->set( $key, array( 'hash' => $hash, 'timestamp' => $timestamp, ) ); return $timestamp; } /** * @return array */ public function getDependencies() { return array( 'mediawiki.language.init' ); } }