MediaWiki
REL1_37
ResourceLoaderLanguageDataModule.php
Go to the documentation of this file.
1
<?php
22
use
MediaWiki\MediaWikiServices
;
23
30
class
ResourceLoaderLanguageDataModule
extends
ResourceLoaderFileModule
{
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
}
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:190
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition
ResourceLoaderContext.php:34
ResourceLoaderContext\getLanguage
getLanguage()
Definition
ResourceLoaderContext.php:183
ResourceLoaderContext\encodeJson
encodeJson( $data)
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
Definition
ResourceLoaderContext.php:432
ResourceLoaderFileModule
Module based on local JavaScript/CSS files.
Definition
ResourceLoaderFileModule.php:40
ResourceLoaderLanguageDataModule
Module for populating language specific data, such as grammar forms.
Definition
ResourceLoaderLanguageDataModule.php:30
ResourceLoaderLanguageDataModule\supportsURLLoading
supportsURLLoading()
Definition
ResourceLoaderLanguageDataModule.php:78
ResourceLoaderLanguageDataModule\$targets
$targets
Definition
ResourceLoaderLanguageDataModule.php:31
ResourceLoaderLanguageDataModule\getData
static getData( $langCode)
Get all the dynamic data for the content language to an array.
Definition
ResourceLoaderLanguageDataModule.php:40
ResourceLoaderLanguageDataModule\enableModuleContentVersion
enableModuleContentVersion()
Definition
ResourceLoaderLanguageDataModule.php:71
ResourceLoaderLanguageDataModule\getScript
getScript(ResourceLoaderContext $context)
Definition
ResourceLoaderLanguageDataModule.php:60
includes
resourceloader
ResourceLoaderLanguageDataModule.php
Generated on Fri Apr 5 2024 23:40:45 for MediaWiki by
1.9.8