MessageCatalogue
class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterface
MessageCatalogue.
Methods
Constructor.
Gets the catalogue locale.
Gets the domains.
Gets the messages within a given domain.
Sets a message translation.
Checks if a message has a translation.
Checks if a message has a translation (it does not take into account the fallback mechanism).
Gets a message translation.
Sets translations for a given domain.
Adds translations for a given domain.
Merges translations from the given Catalogue into the current one.
Merges translations from the given Catalogue into the current one only when the translation does not exist.
Gets the fallback catalogue.
Returns an array of resources loaded to build this collection.
Gets metadata for the given domain and key.
Adds metadata to a message domain.
Deletes metadata for the given key and domain.
Details
at line line 36
__construct(string $locale, array $messages = array())
Constructor.
at line line 45
string
getLocale()
Gets the catalogue locale.
at line line 53
array
getDomains()
Gets the domains.
at line line 61
array
all(string $domain = null)
Gets the messages within a given domain.
If $domain is null, it returns all messages.
at line line 73
set(string $id, string $translation, string $domain = 'messages')
Sets a message translation.
at line line 81
bool
has(string $id, string $domain = 'messages')
Checks if a message has a translation.
at line line 97
bool
defines(string $id, string $domain = 'messages')
Checks if a message has a translation (it does not take into account the fallback mechanism).
at line line 105
string
get(string $id, string $domain = 'messages')
Gets a message translation.
at line line 121
replace(array $messages, string $domain = 'messages')
Sets translations for a given domain.
at line line 131
add(array $messages, string $domain = 'messages')
Adds translations for a given domain.
at line line 143
addCatalogue(MessageCatalogueInterface $catalogue)
Merges translations from the given Catalogue into the current one.
The two catalogues must have the same locale.
at line line 166
addFallbackCatalogue(MessageCatalogueInterface $catalogue)
Merges translations from the given Catalogue into the current one only when the translation does not exist.
This is used to provide default translations when they do not exist for the current locale.
at line line 194
MessageCatalogueInterface|null
getFallbackCatalogue()
Gets the fallback catalogue.
at line line 202
ResourceInterface[]
getResources()
Returns an array of resources loaded to build this collection.
at line line 210
addResource(ResourceInterface $resource)
Adds a resource for this collection.
at line line 218
mixed
getMetadata(string $key = '', string $domain = 'messages')
Gets metadata for the given domain and key.
Passing an empty domain will return an array with all metadata indexed by domain and then by key. Passing an empty key will return an array with all metadata for the given domain.
at line line 238
setMetadata(string $key, mixed $value, string $domain = 'messages')
Adds metadata to a message domain.
at line line 246
deleteMetadata(string $key = '', string $domain = 'messages')
Deletes metadata for the given key and domain.
Passing an empty domain will delete all metadata. Passing an empty key will delete all metadata for the given domain.