MediaWiki  master
MediaWiki\Languages\LanguageConverterFactory Class Reference

An interface for creating language converters. More...

Public Member Functions

 __construct ( $usePigLatinVariant, callable $defaultLanguage)
 
 getLanguageConverter ( $language=null)
 Provide a LanguageConverter for given language. More...
 

Private Member Functions

 classFromCode (string $code)
 Returns Converter's class name for given language code. More...
 

Private Attributes

 $cache = []
 
array $converterClasses
 
 $defaultConverterClass = TrivialLanguageConverter::class
 
callable $defaultLanguage
 callback of () : Language More...
 

Detailed Description

An interface for creating language converters.

Since
1.35

Definition at line 44 of file LanguageConverterFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Languages\LanguageConverterFactory::__construct (   $usePigLatinVariant,
callable  $defaultLanguage 
)
Parameters
bool$usePigLatinVariantshould pig variant of English be used
callable$defaultLanguage- callback of () : Language, should return default language. Used in getLanguageConverter when $language is null.

Definition at line 77 of file LanguageConverterFactory.php.

References MediaWiki\Languages\LanguageConverterFactory\$defaultLanguage.

Member Function Documentation

◆ classFromCode()

MediaWiki\Languages\LanguageConverterFactory::classFromCode ( string  $code)
private

Returns Converter's class name for given language code.

Parameters
string$codecode for which class name should be provided
Returns
string

Definition at line 90 of file LanguageConverterFactory.php.

References MediaWiki\Languages\LanguageConverterFactory\$defaultConverterClass.

Referenced by MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter().

◆ getLanguageConverter()

MediaWiki\Languages\LanguageConverterFactory::getLanguageConverter (   $language = null)

Provide a LanguageConverter for given language.

Parameters
Language | null$languagefor which a LanguageConverter should be provided. If null then LanguageConverter provided for current content language as returned by the callback provided to the constructor..
Returns
ILanguageConverter

Definition at line 104 of file LanguageConverterFactory.php.

References MediaWiki\Languages\LanguageConverterFactory\$defaultLanguage, $lang, and MediaWiki\Languages\LanguageConverterFactory\classFromCode().

Member Data Documentation

◆ $cache

MediaWiki\Languages\LanguageConverterFactory::$cache = []
private

Definition at line 46 of file LanguageConverterFactory.php.

◆ $converterClasses

array MediaWiki\Languages\LanguageConverterFactory::$converterClasses
private
Initial value:
= [
'crh' => CrhConverter::class,
'gan' => GanConverter::class,
'iu' => IuConverter::class,
'kk' => KkConverter::class,
'ku' => KuConverter::class,
'shi' => ShiConverter::class,
'sr' => SrConverter::class,
'tg' => TgConverter::class,
'uz' => UzConverter::class,
'zh' => ZhConverter::class,
]

Definition at line 50 of file LanguageConverterFactory.php.

◆ $defaultConverterClass

MediaWiki\Languages\LanguageConverterFactory::$defaultConverterClass = TrivialLanguageConverter::class
private

◆ $defaultLanguage

callable MediaWiki\Languages\LanguageConverterFactory::$defaultLanguage
private

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