MediaWiki REL1_37
ResourceLoaderLanguageDataModule.php
Go to the documentation of this file.
1<?php
23
31 protected $targets = [ 'desktop', 'mobile' ];
32
40 public static function getData( $langCode ): array {
41 $language = MediaWikiServices::getInstance()->getLanguageFactory()
42 ->getLanguage( $langCode );
43 return [
44 'digitTransformTable' => $language->digitTransformTable(),
45 'separatorTransformTable' => $language->separatorTransformTable(),
46 'minimumGroupingDigits' => $language->minimumGroupingDigits(),
47 'grammarForms' => $language->getGrammarForms(),
48 'grammarTransformations' => $language->getGrammarTransformations(),
49 'pluralRules' => $language->getPluralRules(),
50 'digitGroupingPattern' => $language->digitGroupingPattern(),
51 'fallbackLanguages' => $language->getFallbackLanguages(),
52 'bcp47Map' => LanguageCode::getNonstandardLanguageCodeMapping(),
53 ];
54 }
55
60 public function getScript( ResourceLoaderContext $context ) {
61 return parent::getScript( $context )
62 . 'mw.language.setData('
63 . $context->encodeJson( $context->getLanguage() ) . ','
64 . $context->encodeJson( self::getData( $context->getLanguage() ) )
65 . ');';
66 }
67
71 public function enableModuleContentVersion() {
72 return true;
73 }
74
78 public function supportsURLLoading() {
79 return false;
80 }
81}
MediaWikiServices is the service locator for the application scope of MediaWiki.
Context object that contains information about the state of a specific ResourceLoader web request.
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
Module based on local JavaScript/CSS files.
Module for populating language specific data, such as grammar forms.
static getData( $langCode)
Get all the dynamic data for the content language to an array.