Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\LanguageFallbackChainFactory Class Reference

Object creating LanguageFallbackChain objects in Wikibase. More...

Public Member Functions

 newFromLanguage (Language $language, $mode=self::FALLBACK_ALL)
 Get the fallback chain based a single language, and specified fallback level.
 
 newFromLanguageCode ( $languageCode, $mode=self::FALLBACK_ALL)
 Get the fallback chain based a single language code, and specified fallback level.
 
 newFromContext (IContextSource $context)
 Construct the fallback chain based on a context.
 
 newFromContextAndLanguageCode (IContextSource $context, $languageCode)
 Construct the fallback chain based on a context, but ignore the language info in it and use a specified one instead.
 
 newFromUserAndLanguageCode (User $user, $languageCode)
 Construct the fallback chain based on a user and a language, currently from data provided by Extension:Babel.
 
 buildFromBabel (array $babel)
 Build fallback chain array for a given babel array.
 
 setGetLanguageFallbacksFor ( $getLanguageFallbacksFor)
 

Public Attributes

const FALLBACK_ALL = 0xff
 Fallback levels.
 
const FALLBACK_SELF = 1
 The language itself, e.g.
 
const FALLBACK_VARIANTS = 2
 Other compatible languages that can be translated into the requested language (and translation is automatically done), e.g.
 
const FALLBACK_OTHERS = 4
 All other language from the system fallback chain, e.g.
 

Private Member Functions

 buildFromLanguage ( $language, $mode, array &$chain=[], array &$fetched=[])
 Build fallback chain array for a given language or validated language code.
 
 getBabel ( $languageCode, $user)
 
 getBabelCategoryNames ()
 

Private Attributes

 $languageCache
 
 $userLanguageCache
 
 $getLanguageFallbacksFor = 'Language::getFallbacksFor'
 

Detailed Description

Object creating LanguageFallbackChain objects in Wikibase.

Author
Liangent < liang.nosp@m.ent@.nosp@m.gmail.nosp@m..com >

Member Function Documentation

◆ buildFromBabel()

Wikibase\Lib\LanguageFallbackChainFactory::buildFromBabel ( array  $babel)

Build fallback chain array for a given babel array.

Parameters
array$babel
Returns
LanguageWithConversion[]

◆ buildFromLanguage()

Wikibase\Lib\LanguageFallbackChainFactory::buildFromLanguage (   $language,
  $mode,
array &  $chain = [],
array &  $fetched = [] 
)
private

Build fallback chain array for a given language or validated language code.

Parameters
Language | string$languageLanguage object or language code as string
int$modeBitfield of self::FALLBACK_*
LanguageFallbackChain[]$chainfor recursive calls
bool[]$fetchedfor recursive calls
Exceptions
InvalidArgumentException
Returns
LanguageWithConversion[]

◆ getBabel()

Wikibase\Lib\LanguageFallbackChainFactory::getBabel (   $languageCode,
  $user 
)
private

◆ getBabelCategoryNames()

Wikibase\Lib\LanguageFallbackChainFactory::getBabelCategoryNames ( )
private

◆ newFromContext()

Wikibase\Lib\LanguageFallbackChainFactory::newFromContext ( IContextSource  $context)

Construct the fallback chain based on a context.

Currently it just uses user and language info in it.

Parameters
IContextSource$context
Returns
LanguageFallbackChain

◆ newFromContextAndLanguageCode()

Wikibase\Lib\LanguageFallbackChainFactory::newFromContextAndLanguageCode ( IContextSource  $context,
  $languageCode 
)

Construct the fallback chain based on a context, but ignore the language info in it and use a specified one instead.

Parameters
IContextSource$context
string$languageCode
Returns
LanguageFallbackChain

◆ newFromLanguage()

Wikibase\Lib\LanguageFallbackChainFactory::newFromLanguage ( Language  $language,
  $mode = self::FALLBACK_ALL 
)

Get the fallback chain based a single language, and specified fallback level.

Parameters
Language$language
int$modeBitfield of self::FALLBACK_*
Returns
LanguageFallbackChain

◆ newFromLanguageCode()

Wikibase\Lib\LanguageFallbackChainFactory::newFromLanguageCode (   $languageCode,
  $mode = self::FALLBACK_ALL 
)

Get the fallback chain based a single language code, and specified fallback level.

Parameters
string$languageCode
int$modeBitfield of self::FALLBACK_*
Returns
LanguageFallbackChain

◆ newFromUserAndLanguageCode()

Wikibase\Lib\LanguageFallbackChainFactory::newFromUserAndLanguageCode ( User  $user,
  $languageCode 
)

Construct the fallback chain based on a user and a language, currently from data provided by Extension:Babel.

Parameters
User$user
string$languageCode
Returns
LanguageFallbackChain

◆ setGetLanguageFallbacksFor()

Wikibase\Lib\LanguageFallbackChainFactory::setGetLanguageFallbacksFor (   $getLanguageFallbacksFor)
Parameters
callable$getLanguageFallbacksFor

Member Data Documentation

◆ $getLanguageFallbacksFor

Wikibase\Lib\LanguageFallbackChainFactory::$getLanguageFallbacksFor = 'Language::getFallbacksFor'
private

◆ $languageCache

Wikibase\Lib\LanguageFallbackChainFactory::$languageCache
private

◆ $userLanguageCache

Wikibase\Lib\LanguageFallbackChainFactory::$userLanguageCache
private

◆ FALLBACK_ALL

const Wikibase\Lib\LanguageFallbackChainFactory::FALLBACK_ALL = 0xff

Fallback levels.

◆ FALLBACK_OTHERS

const Wikibase\Lib\LanguageFallbackChainFactory::FALLBACK_OTHERS = 4

All other language from the system fallback chain, e.g.

'de' and 'en' for 'de-formal'.

◆ FALLBACK_SELF

const Wikibase\Lib\LanguageFallbackChainFactory::FALLBACK_SELF = 1

The language itself, e.g.

'en' for 'en'.

◆ FALLBACK_VARIANTS

const Wikibase\Lib\LanguageFallbackChainFactory::FALLBACK_VARIANTS = 2

Other compatible languages that can be translated into the requested language (and translation is automatically done), e.g.

'sr', 'sr-ec' and 'sr-el' for 'sr'.


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