WikiLambda
MediaWiki WikiLambda extension
Loading...
Searching...
No Matches
MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString Class Reference
+ Inheritance diagram for MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString:
+ Collaboration diagram for MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString:

Public Member Functions

 __construct ( $strings=[])
 Create a ZMultiLingualString instance given an array or a ZTypedList of ZMonoLingualString instances.
 
 isValid ()
 @inheritDoc
 
 getSerialized ( $form=self::FORM_CANONICAL)
 @inheritDoc
 
 getZValue ()
 Get the list of ZMonoLingualStrings that represent the value of this ZMultiLingualString.
 
 getValueAsList ()
 Get the values of this ZMultiLingualString in the shape of an array with language as key and string as value.
 
 getStringForLanguageCode (string $languageCode)
 Fetch the ZMultiLingualString's stored value for a given MediaWiki language code (e.g.
 
 isLanguageProvidedValue (string $languageCode)
 Check if the ZMultiLingualString has a stored value for a given MediaWiki language code (e.g.
 
 getStringForLanguage (Language $language)
 Fetch the ZMultiLingualString's stored value for a given MediaWiki language class.
 
 buildStringForLanguage (Language $language)
 Instantiate a chained builder with which you can ask for a fallback in English, or define a placeholder.
 
 setMonoLingualString (ZMonoLingualString $value)
 
 setStringForLanguage (Language $language, string $value)
 
 removeValue (Language $language)
 
- Public Member Functions inherited from MediaWiki\Extension\WikiLambda\ZObjects\ZObject
 getValueByKey (string $key)
 Fetch value of given key from the current ZObject.
 
 setValueByKey (string $key, ZObject $value)
 Set a value of given key in the current ZObject.
 
 isBuiltin ()
 Returns whether this ZObject is a builtin class.
 
 isTypeReference ()
 Returns whether the object type is a ZReference that points to a type.
 
 isTypeFunctionCall ()
 Returns whether the object type is a ZFunctionCall that resolves to a type.
 
 getZTypeObject ()
 Returns either the ZReference or the ZFunctionCall that contain the type of this ZObject (Z1K1)
 
 getZType ()
 Returns a string with the Zid representing the type of this ZObject.
 
 getLinkedZObjects ()
 Return all ZObject Zids that are linked to the current ZObject.
 
 getHumanReadable ( $language=null)
 Convert this ZObject into human readable object by translating all keys and references into the preferred language or its fallbacks.
 
 __toString ()
 Over-ride the default __toString() method to serialise ZObjects into a JSON representation.
 

Static Public Member Functions

static getDefinition ()
 @inheritDoc
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\Extension\WikiLambda\ZObjects\ZObject
const FORM_CANONICAL = 1
 
const FORM_NORMAL = 2
 
- Protected Attributes inherited from MediaWiki\Extension\WikiLambda\ZObjects\ZObject
 $type = null
 
 $data = []
 
 $linkedZObjects = []
 

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::__construct ( $strings = [])

Create a ZMultiLingualString instance given an array or a ZTypedList of ZMonoLingualString instances.

Internally this class bypasses ZTypedList and stores an array with the language Zid as key.

Parameters
ZTypedList | array$strings

Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.

+ Here is the call graph for this function:

Member Function Documentation

◆ buildStringForLanguage()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::buildStringForLanguage ( Language $language)

Instantiate a chained builder with which you can ask for a fallback in English, or define a placeholder.

At the end, either call getString() or getStringAndLanguageCode().

Parameters
Language$language
Returns
StringForLanguageBuilder

◆ getDefinition()

static MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getDefinition ( )
static

@inheritDoc

Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.

◆ getSerialized()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getSerialized ( $form = self::FORM_CANONICAL)

@inheritDoc

Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.

◆ getStringForLanguage()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getStringForLanguage ( Language $language)

Fetch the ZMultiLingualString's stored value for a given MediaWiki language class.

This will walk the language fallback chain, and provide a fallback message if there is no label defined in the given language or any of its fallback languages.

Parameters
Language$languageThe MediaWiki language class in which the string is wanted.
Returns
string|null The string, the value of the wikilambda-multilingualstring-nofallback message, or null.

◆ getStringForLanguageCode()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getStringForLanguageCode ( string $languageCode)

Fetch the ZMultiLingualString's stored value for a given MediaWiki language code (e.g.

'en' or 'zh-hant'). Note that this is a raw fetch and does not walk the language fallback chain; users are expected to use getStringForLanguage() which does.

Parameters
string$languageCodeThe MediaWiki language code in which the string is wanted.
Returns
string The string, or the empty string if .

◆ getValueAsList()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getValueAsList ( )

Get the values of this ZMultiLingualString in the shape of an array with language as key and string as value.

Returns
array

◆ getZValue()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::getZValue ( )

Get the list of ZMonoLingualStrings that represent the value of this ZMultiLingualString.

Returns
array

Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.

◆ isLanguageProvidedValue()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::isLanguageProvidedValue ( string $languageCode)

Check if the ZMultiLingualString has a stored value for a given MediaWiki language code (e.g.

'en' or 'zh-hant'). Note that this is a raw check and does not walk the language fallback chain.

Parameters
string$languageCodeThe MediaWiki language code in which the string is wanted.
Returns
bool If there is a string stored.

◆ isValid()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::isValid ( )

@inheritDoc

Reimplemented from MediaWiki\Extension\WikiLambda\ZObjects\ZObject.

◆ removeValue()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::removeValue ( Language $language)
Parameters
Language$languageThe MediaWiki language class in which the string is to be unset.

◆ setMonoLingualString()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::setMonoLingualString ( ZMonoLingualString $value)
Parameters
ZMonoLingualString$valueThe new value to set.
+ Here is the caller graph for this function:

◆ setStringForLanguage()

MediaWiki\Extension\WikiLambda\ZObjects\ZMultiLingualString::setStringForLanguage ( Language $language,
string $value )
Parameters
Language$languageThe MediaWiki language class in which the string is to be set.
string$valueThe new string to set.

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