MediaWiki  master
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. More...
 
 getAll ( $code, $mode=self::MESSAGES)
 Get the ordered list of fallback languages. More...
 
 getAllIncludingSiteLanguage ( $code)
 Get the ordered list of fallback languages, ending with the fallback language chain for the site language. More...
 
 getFirst ( $code)
 Get the first fallback for a given language. More...
 

Public Attributes

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

Private Attributes

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

Detailed Description

Since
1.35

Definition at line 13 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 46 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 77 of file LanguageFallback.php.

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 118 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 63 of file LanguageFallback.php.

References MediaWiki\Languages\LanguageFallback\getAll().

Member Data Documentation

◆ $fallbackCache

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

Definition at line 36 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 18 of file LanguageFallback.php.

◆ STRICT

const MediaWiki\Languages\LanguageFallback::STRICT = 1

Return a strict fallback chain in getAll.

Since
1.35

Definition at line 24 of file LanguageFallback.php.


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