TranslationString
class TranslationString extends StringBase (View source)
Defines the locale translation string object.
This class represents a translation of a source string to a given language, thus it must have at least a 'language' which is the language code and a 'translation' property which is the translated text of the source string in the specified language.
Properties
| int | $lid | The string identifier. |
from StringBase |
| string | $locations | The string locations indexed by type. |
from StringBase |
| string | $source | The source string. |
from StringBase |
| string | $context | The string context. |
from StringBase |
| string | $version | The string version. |
from StringBase |
| protected StringStorageInterface | $storage | The locale storage this string comes from or is to be saved to. |
from StringBase |
| string | $language | The language code. |
|
| string | $translation | The string translation. |
|
| int | $customized | Integer indicating whether this string is customized. |
|
| protected bool | $isNew | Boolean indicating whether the string object is new. |
Methods
Constructs a new locale string object.
Sets an array of values as object properties.
Gets field values that are set for given field names.
Gets location information for this string.
Checks whether the string has a given location.
Saves string object to storage.
Deletes string object from storage.
Sets the string as customized / not customized.
Checks whether the object is a source string.
Checks whether the object is a translation string.
Gets plain string contained in this object.
Sets the string contained in this object.
Checks whether the object is not saved to storage yet.
Details
__construct(object|array $values = [])
Constructs a new locale string object.
int
getId()
Gets the string unique identifier.
$this
setId($lid)
Sets the string unique identifier.
string
getVersion()
Gets the string version.
$this
setVersion(string $version)
Sets the string version.
array
getPlurals()
Splits string to work with plural values.
$this
setPlurals(array $plurals)
Sets this string using array of plural values.
Serializes plural variants in one string glued by \Drupal\Component\Gettext\PoItem::DELIMITER.
StringStorageInterface
getStorage()
Gets the string storage.
$this
setStorage(StringStorageInterface $storage)
Sets the string storage.
$this
setValues(array $values, bool $override = TRUE)
Sets an array of values as object properties.
array
getValues(array $fields)
Gets field values that are set for given field names.
array
getLocations(bool $check_only = FALSE)
Gets location information for this string.
Locations are arbitrary pairs of type and name strings, used to store information about the origins of the string, like the file name it was found on, the path on which it was discovered, etc.
A string can have any number of locations since the same string may be found on different places of Drupal code and configuration.
$this
addLocation(string $type, string $name)
Adds a location for this string.
bool
hasLocation(string $type, string $name)
Checks whether the string has a given location.
$this
save()
Saves string object to storage.
$this
delete()
Deletes string object from storage.
$this
setCustomized(bool $customized = TRUE)
Sets the string as customized / not customized.
bool
isSource()
Checks whether the object is a source string.
bool
isTranslation()
Checks whether the object is a translation string.
string
getString()
Gets plain string contained in this object.
$this
setString(string $string)
Sets the string contained in this object.
bool
isNew()
Checks whether the object is not saved to storage yet.