Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/157180
Change subject: ResourceLoaderFileModule: Support fallback in 'languageScripts'
......................................................................
ResourceLoaderFileModule: Support fallback in 'languageScripts'
Bug: 58139
Change-Id: Idd7657aa48a9eb2b075a85f77e066b425f330890
---
M includes/resourceloader/ResourceLoaderFileModule.php
1 file changed, 25 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/80/157180/1
diff --git a/includes/resourceloader/ResourceLoaderFileModule.php
b/includes/resourceloader/ResourceLoaderFileModule.php
index 0c84700e..f56cb1c 100644
--- a/includes/resourceloader/ResourceLoaderFileModule.php
+++ b/includes/resourceloader/ResourceLoaderFileModule.php
@@ -533,7 +533,7 @@
$files,
$this->scripts,
$context->getDebug() ? $this->debugScripts : array(),
- self::tryForKey( $this->languageScripts,
$context->getLanguage() ),
+ $this->getLanguageScripts( $context->getLanguage() ),
self::tryForKey( $this->skinScripts,
$context->getSkin(), 'default' ),
$this->loaderScripts
);
@@ -697,7 +697,7 @@
protected function getScriptFiles( ResourceLoaderContext $context ) {
$files = array_merge(
$this->scripts,
- self::tryForKey( $this->languageScripts,
$context->getLanguage() ),
+ $this->getLanguageScripts( $context->getLanguage() ),
self::tryForKey( $this->skinScripts,
$context->getSkin(), 'default' )
);
if ( $context->getDebug() ) {
@@ -708,6 +708,29 @@
}
/**
+ * Gets the set of language scripts for the given language,
+ * possibly using a fallback
+ *
+ * @param string $lang
+ * @return array
+ */
+ private function getLanguageScripts( $lang ) {
+ $scripts = self::tryForKey( $this->languageScripts, $lang );
+ if ( $scripts ) {
+ return $scripts;
+ }
+ $fallbacks = Language::getFallbacksFor( $lang );
+ foreach ( $fallbacks as $lang ) {
+ $scripts = self::tryForKey( $this->languageScripts,
$lang );
+ if ( $scripts ) {
+ return $scripts;
+ }
+ }
+
+ return array();
+ }
+
+ /**
* Get a list of file paths for all styles in this module, in order of
proper inclusion.
*
* @param ResourceLoaderContext $context
--
To view, visit https://gerrit.wikimedia.org/r/157180
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd7657aa48a9eb2b075a85f77e066b425f330890
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits