MediaWiki REL1_39
LanguageDataModule.php
Go to the documentation of this file.
1<?php
23
24use LanguageCode;
26
34 protected $targets = [ 'desktop', 'mobile' ];
35
43 public static function getData( $langCode ): array {
44 $language = MediaWikiServices::getInstance()->getLanguageFactory()
45 ->getLanguage( $langCode );
46 return [
47 'digitTransformTable' => $language->digitTransformTable(),
48 'separatorTransformTable' => $language->separatorTransformTable(),
49 'minimumGroupingDigits' => $language->minimumGroupingDigits(),
50 'grammarForms' => $language->getGrammarForms(),
51 'grammarTransformations' => $language->getGrammarTransformations(),
52 'pluralRules' => $language->getPluralRules(),
53 'digitGroupingPattern' => $language->digitGroupingPattern(),
54 'fallbackLanguages' => $language->getFallbackLanguages(),
55 'bcp47Map' => LanguageCode::getNonstandardLanguageCodeMapping(),
56 ];
57 }
58
63 public function getScript( Context $context ) {
64 return parent::getScript( $context )
65 . 'mw.language.setData('
66 . $context->encodeJson( $context->getLanguage() ) . ','
67 . $context->encodeJson( self::getData( $context->getLanguage() ) )
68 . ');';
69 }
70
74 public function enableModuleContentVersion() {
75 return true;
76 }
77
81 public function supportsURLLoading() {
82 return false;
83 }
84}
85
87class_alias( LanguageDataModule::class, 'ResourceLoaderLanguageDataModule' );
Methods for dealing with language codes.
Service locator for MediaWiki core services.
Context object that contains information about the state of a specific ResourceLoader web request.
Definition Context.php:46
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
Definition Context.php:493
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.