- // 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\"" );
+ }