MediaWiki REL1_35
MediaWiki\Languages\LanguageFallback Class Reference
Collaboration diagram for MediaWiki\Languages\LanguageFallback:

Public Member Functions

 __construct ( $siteLangCode, LocalisationCache $localisationCache, LanguageNameUtils $langNameUtils)
 Do not call this directly.
 
 getAll ( $code, $mode=self::MESSAGES)
 Get the ordered list of fallback languages.
 
 getAllIncludingSiteLanguage ( $code)
 Get the ordered list of fallback languages, ending with the fallback language chain for the site language.
 
 getFirst ( $code)
 Get the first fallback for a given language.
 

Public Attributes

const MESSAGES = 0
 Return a fallback chain for messages in getAll.
 
const STRICT = 1
 Return a strict fallback chain in getAll.
 

Private Attributes

array $fallbackCache = []
 
LanguageNameUtils $langNameUtils
 
LocalisationCache $localisationCache
 
string $siteLangCode
 

Detailed Description

Since
1.35

Definition at line 31 of file LanguageFallback.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Languages\LanguageFallback::__construct (   $siteLangCode,
LocalisationCache  $localisationCache,
LanguageNameUtils  $langNameUtils 
)

Do not call this directly.

Use MediaWikiServices.

Since
1.35
Parameters
string$siteLangCodeLanguage code of the site, typically $wgLanguageCode
LocalisationCache$localisationCache
LanguageNameUtils$langNameUtils

Definition at line 64 of file LanguageFallback.php.

References MediaWiki\Languages\LanguageFallback\$langNameUtils, MediaWiki\Languages\LanguageFallback\$localisationCache, and MediaWiki\Languages\LanguageFallback\$siteLangCode.

Member Function Documentation

◆ getAll()

MediaWiki\Languages\LanguageFallback::getAll (   $code,
  $mode = self::MESSAGES 
)

Get the ordered list of fallback languages.

Since
1.35
Parameters
string$codeLanguage code
int$modeFallback mode, either MESSAGES (which always falls back to 'en'), or STRICT (which only falls back to 'en' when explicitly defined)
Exceptions
InvalidArgumentExceptionIf $mode is invalid
Returns
array List of language codes

Definition at line 95 of file LanguageFallback.php.

References MediaWiki\Languages\LanguageFallback\MESSAGES, and MediaWiki\Languages\LanguageFallback\STRICT.

Referenced by MediaWiki\Languages\LanguageFallback\getAllIncludingSiteLanguage(), and MediaWiki\Languages\LanguageFallback\getFirst().

◆ getAllIncludingSiteLanguage()

MediaWiki\Languages\LanguageFallback::getAllIncludingSiteLanguage (   $code)

Get the ordered list of fallback languages, ending with the fallback language chain for the site language.

The site fallback list begins with the site language itself.

Since
1.35
Parameters
string$codeLanguage code
Returns
array [ fallbacks, site fallbacks ]

Definition at line 136 of file LanguageFallback.php.

References MediaWiki\Languages\LanguageFallback\getAll().

◆ getFirst()

MediaWiki\Languages\LanguageFallback::getFirst (   $code)

Get the first fallback for a given language.

Since
1.35
Parameters
string$code
Returns
string|null

Definition at line 81 of file LanguageFallback.php.

References MediaWiki\Languages\LanguageFallback\getAll().

Member Data Documentation

◆ $fallbackCache

array MediaWiki\Languages\LanguageFallback::$fallbackCache = []
private

Definition at line 54 of file LanguageFallback.php.

◆ $langNameUtils

LanguageNameUtils MediaWiki\Languages\LanguageFallback::$langNameUtils
private

◆ $localisationCache

LocalisationCache MediaWiki\Languages\LanguageFallback::$localisationCache
private

◆ $siteLangCode

string MediaWiki\Languages\LanguageFallback::$siteLangCode
private

◆ MESSAGES

const MediaWiki\Languages\LanguageFallback::MESSAGES = 0

Return a fallback chain for messages in getAll.

Since
1.35

Definition at line 36 of file LanguageFallback.php.

Referenced by MediaWiki\Languages\LanguageFallback\getAll().

◆ STRICT

const MediaWiki\Languages\LanguageFallback::STRICT = 1

Return a strict fallback chain in getAll.

Since
1.35

Definition at line 42 of file LanguageFallback.php.

Referenced by MediaWiki\Languages\LanguageFallback\getAll().


The documentation for this class was generated from the following file: