Translatable
in
Base interface of multilingual strings.
Tags
Table of Contents
Methods
- __serialize() : array<string|int, mixed>
- Returns a serializable representation of this multilingual string.
- __toString() : string
- Returns a plain string representation of this multilingual string.
- __unserialize() : void
- Restores the object from serialized state.
- equals() : bool
- Indicates whether some other multilingual string is equal to this one.
- get() : string|null
- Returns variant of this multilingual string in the given language.
- getLanguages() : array<string|int, string>
- Lists identifiers of all language variants defined by this multilingual string.
- has() : bool
- Indicates whether this multilingual string contains the given language variant.
- isEmpty() : bool
- Indicates whether this string does not contain any language variants or all of them are an empty string.
- toArray() : array<string, string>
- Returns all language variants contained in this object as an array.
Methods
__serialize()
Returns a serializable representation of this multilingual string.
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —serializable array
__toString()
Returns a plain string representation of this multilingual string.
public
__toString() : string
This method is mainly used for debugging purposes and clients should not depend on any particular output format. A translator object must be used for correct retrieval of a concrete language variant.
Return values
string —plain string
__unserialize()
Restores the object from serialized state.
public
__unserialize(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
-
serialized array
equals()
Indicates whether some other multilingual string is equal to this one.
public
equals(Translatable $other) : bool
The equals
method implements an equivalence relation:
- It is reflexive: for any
$x
,$x->equals($x)
returnstrue
. - It is symmetric: for any
$x
and$y
,$x->equals($y)
returnstrue
if and only if$y->equals($x)
returnstrue
. - It is transitive: for any
$x
,$y
and$z
, if$x->equals($y)
returnstrue
and$y->equals($z)
returnstrue
, then$x->equals($z)
returnstrue
. - It is consistent: for any
$x
and$y
, multiple invocations of$x->equals($y)
consistently returntrue
or consistently returnfalse
, provided no language variant in either string is modified.
Parameters
- $other : Translatable
-
the multilingual string with which to compare
Return values
bool —true
if the strings are equal, false
if not
get()
Returns variant of this multilingual string in the given language.
public
get(string $language) : string|null
Value of the language
parameter can be an arbitrary string, as the library does not impose any constraints on
language variant identifiers.
Parameters
- $language : string
-
language variant to return
Return values
string|null —plain string in the given language or null
if the requested variant is not defined
getLanguages()
Lists identifiers of all language variants defined by this multilingual string.
public
getLanguages() : array<string|int, string>
Return values
array<string|int, string> —language variant identifiers
has()
Indicates whether this multilingual string contains the given language variant.
public
has(string $language) : bool
Parameters
- $language : string
-
language variant to check
Return values
bool —true
if the given language variant is defined, false
if not
isEmpty()
Indicates whether this string does not contain any language variants or all of them are an empty string.
public
isEmpty() : bool
Return values
bool —true
if no language variants are defined or all are empty string, false
otherwise
toArray()
Returns all language variants contained in this object as an array.
public
toArray() : array<string, string>
Array keys are language variant identifiers and values are strings beloging to the respective variants.
Return values
array<string, string> —language variants