MediaWiki REL1_40
LanguageDataModule.php
Go to the documentation of this file.
1<?php
23
24use LanguageCode;
26
34
42 public static function getData( $langCode ): array {
43 $language = MediaWikiServices::getInstance()->getLanguageFactory()
44 ->getLanguage( $langCode );
45 return [
46 'digitTransformTable' => $language->digitTransformTable(),
47 'separatorTransformTable' => $language->separatorTransformTable(),
48 'minimumGroupingDigits' => $language->minimumGroupingDigits(),
49 'grammarForms' => $language->getGrammarForms(),
50 'grammarTransformations' => $language->getGrammarTransformations(),
51 'pluralRules' => $language->getPluralRules(),
52 'digitGroupingPattern' => $language->digitGroupingPattern(),
53 'fallbackLanguages' => $language->getFallbackLanguages(),
54 'bcp47Map' => LanguageCode::getNonstandardLanguageCodeMapping(),
55 ];
56 }
57
62 public function getScript( Context $context ) {
63 return parent::getScript( $context )
64 . 'mw.language.setData('
65 . $context->encodeJson( $context->getLanguage() ) . ','
66 . $context->encodeJson( self::getData( $context->getLanguage() ) )
67 . ');';
68 }
69
73 public function enableModuleContentVersion() {
74 return true;
75 }
76
80 public function supportsURLLoading() {
81 return false;
82 }
83}
84
86class_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:494
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.