MessageCatalogue
in package
implements
MessageCatalogueInterface, MetadataAwareInterface
Tags
Interfaces, Classes, Traits and Enums
- MessageCatalogueInterface
- MessageCatalogueInterface.
- MetadataAwareInterface
- MetadataAwareInterface.
Table of Contents
- $fallbackCatalogue : mixed
- $locale : mixed
- $messages : mixed
- $metadata : mixed
- $parent : mixed
- $resources : mixed
- __construct() : mixed
- add() : mixed
- Adds translations for a given domain.
- addCatalogue() : mixed
- Merges translations from the given Catalogue into the current one.
- addFallbackCatalogue() : mixed
- Merges translations from the given Catalogue into the current one only when the translation does not exist.
- addResource() : mixed
- Adds a resource for this collection.
- all() : array<string|int, mixed>
- Gets the messages within a given domain.
- defines() : bool
- Checks if a message has a translation (it does not take into account the fallback mechanism).
- deleteMetadata() : mixed
- Deletes metadata for the given key and domain.
- get() : string
- Gets a message translation.
- getDomains() : array<string|int, mixed>
- Gets the domains.
- getFallbackCatalogue() : self|null
- Gets the fallback catalogue.
- getLocale() : string
- Gets the catalogue locale.
- getMetadata() : mixed
- Gets metadata for the given domain and key.
- getResources() : array<string|int, ResourceInterface>
- Returns an array of resources loaded to build this collection.
- has() : bool
- Checks if a message has a translation.
- replace() : mixed
- Sets translations for a given domain.
- set() : mixed
- Sets a message translation.
- setMetadata() : mixed
- Adds metadata to a message domain.
- addMetadata() : mixed
- Adds current values with the new values.
Properties
$fallbackCatalogue
private
mixed
$fallbackCatalogue
$locale
private
mixed
$locale
$messages
private
mixed
$messages
= []
$metadata
private
mixed
$metadata
= []
$parent
private
mixed
$parent
$resources
private
mixed
$resources
= []
Methods
__construct()
public
__construct(string $locale[, array<string|int, mixed> $messages = [] ]) : mixed
Parameters
- $locale : string
-
The locale
- $messages : array<string|int, mixed> = []
-
An array of messages classified by domain
Return values
mixed —add()
Adds translations for a given domain.
public
add(mixed $messages[, mixed $domain = 'messages' ]) : mixed
Parameters
- $messages : mixed
-
An array of translations
- $domain : mixed = 'messages'
-
The domain name
Return values
mixed —addCatalogue()
Merges translations from the given Catalogue into the current one.
public
addCatalogue(MessageCatalogueInterface $catalogue) : mixed
Parameters
- $catalogue : MessageCatalogueInterface
Return values
mixed —addFallbackCatalogue()
Merges translations from the given Catalogue into the current one only when the translation does not exist.
public
addFallbackCatalogue(MessageCatalogueInterface $catalogue) : mixed
Parameters
- $catalogue : MessageCatalogueInterface
Return values
mixed —addResource()
Adds a resource for this collection.
public
addResource(ResourceInterface $resource) : mixed
Parameters
- $resource : ResourceInterface
Return values
mixed —all()
Gets the messages within a given domain.
public
all([mixed $domain = null ]) : array<string|int, mixed>
Parameters
- $domain : mixed = null
-
The domain name
Return values
array<string|int, mixed> —An array of messages
defines()
Checks if a message has a translation (it does not take into account the fallback mechanism).
public
defines(mixed $id[, mixed $domain = 'messages' ]) : bool
Parameters
- $id : mixed
-
The message id
- $domain : mixed = 'messages'
-
The domain name
Return values
bool —true if the message has a translation, false otherwise
deleteMetadata()
Deletes metadata for the given key and domain.
public
deleteMetadata([mixed $key = '' ][, mixed $domain = 'messages' ]) : mixed
Parameters
- $key : mixed = ''
-
The key
- $domain : mixed = 'messages'
-
The domain name
Return values
mixed —get()
Gets a message translation.
public
get(mixed $id[, mixed $domain = 'messages' ]) : string
Parameters
- $id : mixed
-
The message id
- $domain : mixed = 'messages'
-
The domain name
Return values
string —The message translation
getDomains()
Gets the domains.
public
getDomains() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of domains
getFallbackCatalogue()
Gets the fallback catalogue.
public
getFallbackCatalogue() : self|null
Return values
self|null —A MessageCatalogueInterface instance or null when no fallback has been set
getLocale()
Gets the catalogue locale.
public
getLocale() : string
Return values
string —The locale
getMetadata()
Gets metadata for the given domain and key.
public
getMetadata([mixed $key = '' ][, mixed $domain = 'messages' ]) : mixed
Parameters
- $key : mixed = ''
-
The key
- $domain : mixed = 'messages'
-
The domain name
Return values
mixed —The value that was set or an array with the domains/keys or null
getResources()
Returns an array of resources loaded to build this collection.
public
getResources() : array<string|int, ResourceInterface>
Return values
array<string|int, ResourceInterface> —An array of resources
has()
Checks if a message has a translation.
public
has(mixed $id[, mixed $domain = 'messages' ]) : bool
Parameters
- $id : mixed
-
The message id
- $domain : mixed = 'messages'
-
The domain name
Return values
bool —true if the message has a translation, false otherwise
replace()
Sets translations for a given domain.
public
replace(mixed $messages[, mixed $domain = 'messages' ]) : mixed
Parameters
- $messages : mixed
-
An array of translations
- $domain : mixed = 'messages'
-
The domain name
Return values
mixed —set()
Sets a message translation.
public
set(mixed $id, mixed $translation[, mixed $domain = 'messages' ]) : mixed
Parameters
- $id : mixed
-
The message id
- $translation : mixed
-
The messages translation
- $domain : mixed = 'messages'
-
The domain name
Return values
mixed —setMetadata()
Adds metadata to a message domain.
public
setMetadata(mixed $key, mixed $value[, mixed $domain = 'messages' ]) : mixed
Parameters
- $key : mixed
-
The key
- $value : mixed
-
The value
- $domain : mixed = 'messages'
-
The domain name
Return values
mixed —addMetadata()
Adds current values with the new values.
private
addMetadata(array<string|int, mixed> $values) : mixed
Parameters
- $values : array<string|int, mixed>
-
Values to add