MediaWiki  master
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(),
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 }
ResourceLoaderLanguageDataModule\supportsURLLoading
supportsURLLoading()
Definition: ResourceLoaderLanguageDataModule.php:78
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition: ResourceLoaderContext.php:33
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:165
ResourceLoaderLanguageDataModule
Module for populating language specific data, such as grammar forms.
Definition: ResourceLoaderLanguageDataModule.php:30
ResourceLoaderLanguageDataModule\getScript
getScript(ResourceLoaderContext $context)
Definition: ResourceLoaderLanguageDataModule.php:60
ResourceLoaderLanguageDataModule\$targets
$targets
Definition: ResourceLoaderLanguageDataModule.php:31
ResourceLoaderFileModule
Module based on local JavaScript/CSS files.
Definition: ResourceLoaderFileModule.php:39
ResourceLoaderLanguageDataModule\enableModuleContentVersion
enableModuleContentVersion()
Definition: ResourceLoaderLanguageDataModule.php:71
ResourceLoaderContext\getLanguage
getLanguage()
Definition: ResourceLoaderContext.php:156
ResourceLoaderLanguageDataModule\getData
static getData( $langCode)
Get all the dynamic data for the content language to an array.
Definition: ResourceLoaderLanguageDataModule.php:40
LanguageCode\getNonstandardLanguageCodeMapping
static getNonstandardLanguageCodeMapping()
Returns a mapping of non-standard language codes used by (current and previous version of) MediaWiki,...
Definition: LanguageCode.php:140
ResourceLoaderContext\encodeJson
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
Definition: ResourceLoaderContext.php:405