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

Object representing either a verbatim language or a converted language. More...

Public Member Functions

 getLanguageCode ()
 Get the code of the language this object wraps.
 
 getSourceLanguageCode ()
 Get the code of the source language defined.
 
 getFetchLanguageCode ()
 Get the code of the language where data should be fetched.
 
 translate ( $text)
 Translate data after fetching them.
 

Static Public Member Functions

static validateLanguageCode ( $code)
 Validate a language code.
 
static factory ( $language, $sourceLanguage=null)
 Get a LanguageWithConversion object.
 

Private Member Functions

 __construct ( $languageCode, $sourceLanguageCode=null, Language $parentLanguage=null)
 
 prepareForTranslate ( $text)
 Insert a text snippet which will be translated later.
 
 executeTranslate ()
 Really execute translation.
 

Private Attributes

 $languageCode
 
 $sourceLanguageCode
 
 $parentLanguage
 
 $translateCache = []
 
 $translatePool = []
 

Static Private Attributes

static $objectCache = []
 

Detailed Description

Object representing either a verbatim language or a converted language.

Used for items in language fallback chain.

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

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\LanguageWithConversion::__construct ( $languageCode,
$sourceLanguageCode = null,
Language $parentLanguage = null )
private
Parameters
string$languageCode
null | string$sourceLanguageCode
null | Language$parentLanguage

Member Function Documentation

◆ executeTranslate()

Wikibase\Lib\LanguageWithConversion::executeTranslate ( )
private

Really execute translation.

◆ factory()

static Wikibase\Lib\LanguageWithConversion::factory ( $language,
$sourceLanguage = null )
static

Get a LanguageWithConversion object.

Parameters
Language | string$languageLanguage (code) for this object
Language | string | null$sourceLanguageSource language (code) if this is a converted language, or null
Exceptions
InvalidArgumentException
Returns
self

◆ getFetchLanguageCode()

Wikibase\Lib\LanguageWithConversion::getFetchLanguageCode ( )

Get the code of the language where data should be fetched.

Returns
string

◆ getLanguageCode()

Wikibase\Lib\LanguageWithConversion::getLanguageCode ( )

Get the code of the language this object wraps.

Returns
string

◆ getSourceLanguageCode()

Wikibase\Lib\LanguageWithConversion::getSourceLanguageCode ( )

Get the code of the source language defined.

Returns
string|null

◆ prepareForTranslate()

Wikibase\Lib\LanguageWithConversion::prepareForTranslate ( $text)
private

Insert a text snippet which will be translated later.

Due to the implementation of language converter, massive calls with short text snippets may introduce big overhead. If it's foreseeable that some text will be translated later, add it here for batched translation.

Does nothing if this is not a converted language.

Parameters
string$text

◆ translate()

Wikibase\Lib\LanguageWithConversion::translate ( $text)

Translate data after fetching them.

Parameters
string$textData to transform
Returns
string

◆ validateLanguageCode()

static Wikibase\Lib\LanguageWithConversion::validateLanguageCode ( $code)
static

Validate a language code.

Logic taken from class Language.

Parameters
string$codeLanguage code
Returns
string Validated and normalized code.
Exceptions
InvalidArgumentExceptionon invalid code

Member Data Documentation

◆ $languageCode

Wikibase\Lib\LanguageWithConversion::$languageCode
private

◆ $objectCache

Wikibase\Lib\LanguageWithConversion::$objectCache = []
staticprivate

◆ $parentLanguage

Wikibase\Lib\LanguageWithConversion::$parentLanguage
private

◆ $sourceLanguageCode

Wikibase\Lib\LanguageWithConversion::$sourceLanguageCode
private

◆ $translateCache

Wikibase\Lib\LanguageWithConversion::$translateCache = []
private

◆ $translatePool

Wikibase\Lib\LanguageWithConversion::$translatePool = []
private

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