MessageCatalogue
in package
implements
MessageCatalogueInterface, MetadataAwareInterface
Tags
Table of Contents
Interfaces
- MessageCatalogueInterface
- MessageCatalogueInterface.
- MetadataAwareInterface
- MetadataAwareInterface.
Properties
- $fallbackCatalogue : mixed
- $locale : string
- $messages : array<string|int, mixed>
- $metadata : array<string|int, mixed>
- $parent : self|null
- $resources : array<string|int, mixed>
Methods
- __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() : MessageCatalogueInterface|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
= null
$locale
private
string
$locale
$messages
private
array<string|int, mixed>
$messages
= []
$metadata
private
array<string|int, mixed>
$metadata
= []
$parent
private
self|null
$parent
= null
$resources
private
array<string|int, mixed>
$resources
= []
Methods
__construct()
public
__construct(string $locale[, array<string|int, mixed> $messages = [] ]) : mixed
Parameters
- $locale : string
- $messages : array<string|int, mixed> = []
-
An array of messages classified by domain
add()
Adds translations for a given domain.
public
add(array<string|int, mixed> $messages[, string $domain = 'messages' ]) : mixed
Parameters
- $messages : array<string|int, mixed>
-
An array of translations
- $domain : string = 'messages'
-
The domain name
addCatalogue()
Merges translations from the given Catalogue into the current one.
public
addCatalogue(MessageCatalogueInterface $catalogue) : mixed
Parameters
- $catalogue : MessageCatalogueInterface
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
addResource()
Adds a resource for this collection.
public
addResource(ResourceInterface $resource) : mixed
Parameters
- $resource : ResourceInterface
all()
Gets the messages within a given domain.
public
all([string $domain = null ]) : array<string|int, mixed>
Parameters
- $domain : string = null
-
The domain name
Return values
array<string|int, mixed>defines()
Checks if a message has a translation (it does not take into account the fallback mechanism).
public
defines(string $id[, string $domain = 'messages' ]) : bool
Parameters
- $id : string
-
The message id
- $domain : string = 'messages'
-
The domain name
Return values
booldeleteMetadata()
Deletes metadata for the given key and domain.
public
deleteMetadata([string $key = '' ][, string $domain = 'messages' ]) : mixed
Parameters
- $key : string = ''
- $domain : string = 'messages'
get()
Gets a message translation.
public
get(string $id[, string $domain = 'messages' ]) : string
Parameters
- $id : string
-
The message id
- $domain : string = 'messages'
-
The domain name
Return values
stringgetDomains()
Gets the domains.
public
getDomains() : array<string|int, mixed>
Return values
array<string|int, mixed>getFallbackCatalogue()
Gets the fallback catalogue.
public
getFallbackCatalogue() : MessageCatalogueInterface|null
Return values
MessageCatalogueInterface|nullgetLocale()
Gets the catalogue locale.
public
getLocale() : string
Return values
stringgetMetadata()
Gets metadata for the given domain and key.
public
getMetadata([string $key = '' ][, string $domain = 'messages' ]) : mixed
Parameters
- $key : string = ''
- $domain : string = 'messages'
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>has()
Checks if a message has a translation.
public
has(string $id[, string $domain = 'messages' ]) : bool
Parameters
- $id : string
-
The message id
- $domain : string = 'messages'
-
The domain name
Return values
boolreplace()
Sets translations for a given domain.
public
replace(array<string|int, mixed> $messages[, string $domain = 'messages' ]) : mixed
Parameters
- $messages : array<string|int, mixed>
-
An array of translations
- $domain : string = 'messages'
-
The domain name
set()
Sets a message translation.
public
set(string $id, string $translation[, string $domain = 'messages' ]) : mixed
Parameters
- $id : string
-
The message id
- $translation : string
-
The messages translation
- $domain : string = 'messages'
-
The domain name
setMetadata()
Adds metadata to a message domain.
public
setMetadata(string $key, mixed $value[, string $domain = 'messages' ]) : mixed
Parameters
- $key : string
- $value : mixed
- $domain : string = 'messages'
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