}
# Fill in the fallback if it's not there already
- if ( is_null( $coreData['fallback'] ) ) {
- $coreData['fallback'] = $code === 'en' ? false : 'en';
- }
- if ( $coreData['fallback'] === false ) {
- $coreData['fallbackSequence'] = [];
+ if ( ( is_null( $coreData['fallback'] ) || $coreData['fallback'] === false ) && $code === 'en' ) {
+ $coreData['fallback'] = false;
+ $coreData['originalFallbackSequence'] = $coreData['fallbackSequence'] = [];
} else {
- $coreData['fallbackSequence'] = array_map( 'trim', explode( ',', $coreData['fallback'] ) );
+ if ( !is_null( $coreData['fallback'] ) ) {
+ $coreData['fallbackSequence'] = array_map( 'trim', explode( ',', $coreData['fallback'] ) );
+ } else {
+ $coreData['fallbackSequence'] = [];
+ }
$len = count( $coreData['fallbackSequence'] );
- # Ensure that the sequence ends at en
- if ( $coreData['fallbackSequence'][$len - 1] !== 'en' ) {
+ # Before we add the 'en' fallback for messages, keep a copy of
+ # the original fallback sequence
+ $coreData['originalFallbackSequence'] = $coreData['fallbackSequence'];
+
+ # Ensure that the sequence ends at 'en' for messages
+ if ( !$len || $coreData['fallbackSequence'][$len - 1] !== 'en' ) {
$coreData['fallbackSequence'][] = 'en';
}
}
if ( isset( $desc['lang'][$contextLang] ) ) {
return $this->basePath . '/' . $desc['lang'][$contextLang];
}
- $fallbacks = Language::getFallbacksFor( $contextLang );
+ $fallbacks = Language::getFallbacksFor( $contextLang, Language::STRICT_FALLBACKS );
foreach ( $fallbacks as $lang ) {
- // Images will fallback to 'default' instead of 'en', except for 'en-*' variants
- if (
- ( $lang !== 'en' || substr( $contextLang, 0, 3 ) === 'en-' ) &&
- isset( $desc['lang'][$lang] )
- ) {
+ if ( isset( $desc['lang'][$lang] ) ) {
return $this->basePath . '/' . $desc['lang'][$lang];
}
}
static public $mLangObjCache = [];
+ /**
+ * Return a fallback chain for messages in getFallbacksFor
+ * @since 1.32
+ */
+ const MESSAGES_FALLBACKS = 0;
+
+ /**
+ * Return a strict fallback chain in getFallbacksFor
+ * @since 1.32
+ */
+ const STRICT_FALLBACKS = 1;
+
static public $mWeekdayMsgs = [
'sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
'friday', 'saturday'
*
* @since 1.19
* @param string $code Language code
- * @return array Non-empty array, ending in "en"
+ * @param int $mode Fallback mode, either MESSAGES_FALLBACKS (which always falls back to 'en'),
+ * or STRICT_FALLBACKS (whic honly falls back to 'en' when explicitly defined)
+ * @throws MWException
+ * @return array List of language codes
*/
- public static function getFallbacksFor( $code ) {
+ public static function getFallbacksFor( $code, $mode = self::MESSAGES_FALLBACKS ) {
if ( $code === 'en' || !self::isValidBuiltInCode( $code ) ) {
return [];
}
- // For unknown languages, fallbackSequence returns an empty array,
- // hardcode fallback to 'en' in that case.
- return self::getLocalisationCache()->getItem( $code, 'fallbackSequence' ) ?: [ 'en' ];
+ switch ( $mode ) {
+ case self::MESSAGES_FALLBACKS:
+ // For unknown languages, fallbackSequence returns an empty array,
+ // hardcode fallback to 'en' in that case as English messages are
+ // always defined.
+ return self::getLocalisationCache()->getItem( $code, 'fallbackSequence' ) ?: [ 'en' ];
+ case self::STRICT_FALLBACKS:
+ // Use this mode when you don't want to fallback to English unless
+ // explicitly defined, for example when you have language-variant icons
+ // and an international language-independent fallback.
+ return self::getLocalisationCache()->getItem( $code, 'originalFallbackSequence' );
+ default:
+ throw new MWException( "Invalid fallback mode \"$mode\"" );
+ }
}
/**
* @file
*
*/
+
+$fallback = 'en';
--- /dev/null
+<?php
+/** Canadian English (Canadian English)
+ *
+ * To improve a translation please visit https://translatewiki.net
+ *
+ * @ingroup Language
+ * @file
+ *
+ */
+
+$fallback = 'en';
*
*/
+$fallback = 'en';
+
$specialPageAliases = [
'Uncategorizedcategories' => [ 'UncategorisedCategories' ],
'Uncategorizedimages' => [ 'UncategorisedFiles', 'UncategorisedImages' ],
--- /dev/null
+<?php
+/** Jamaican Creole English (Patois)
+ *
+ * To improve a translation please visit https://translatewiki.net
+ *
+ * @ingroup Language
+ * @file
+ *
+ */
+
+$fallback = 'en';
--- /dev/null
+<?php
+/** Pitkern (Pitkern)
+ *
+ * To improve a translation please visit https://translatewiki.net
+ *
+ * @ingroup Language
+ * @file
+ *
+ */
+
+$fallback = 'en';
*
*/
+$fallback = 'en';
+
$namespaceNames = [
NS_MEDIA => 'Media',
NS_SPECIAL => 'Special',