Class Package
Message Catalog
Property Summary
-
$fallback protected
string|null
The name of a fallback package to use when a message key does not exist.
-
$formatter protected
string
The name of the formatter to use when formatting translated messages.
-
$messages protected
array<string|array>
Message keys and translations in this package.
Method Summary
-
__construct() public
Constructor.
-
addMessage() public
Adds one message for this package.
-
addMessages() public
Adds new messages for this package.
-
getFallback() public
Gets the fallback package name.
-
getFormatter() public
Gets the formatter name for this package.
-
getMessage() public
Gets the message of the given key for this package.
-
getMessages() public
Gets the messages for this package.
-
setFallback() public
Sets the fallback package name.
-
setFormatter() public
Sets the formatter name for this package.
-
setMessages() public
Sets the messages for this package.
Method Detail
__construct() ¶ public
__construct(string $formatter = 'default', string|null $fallback = null, array<string|array> $messages = [])
Constructor.
Parameters
-
string
$formatter optional The name of the formatter to use.
-
string|null
$fallback optional The name of the fallback package to use.
-
array<string|array>
$messages optional The messages in this package.
addMessage() ¶ public
addMessage(string $key, string|array $message): void
Adds one message for this package.
Parameters
-
string
$key the key of the message
-
string|array
$message the actual message
Returns
void
addMessages() ¶ public
addMessages(array<string|array> $messages): void
Adds new messages for this package.
Parameters
-
array<string|array>
$messages The messages to add in this package.
Returns
void
getFallback() ¶ public
getFallback(): string|null
Gets the fallback package name.
Returns
string|null
getFormatter() ¶ public
getFormatter(): string
Gets the formatter name for this package.
Returns
string
getMessage() ¶ public
getMessage(string $key): string|array|false
Gets the message of the given key for this package.
Parameters
-
string
$key the key of the message to return
Returns
string|array|false
getMessages() ¶ public
getMessages(): array<string|array>
Gets the messages for this package.
Returns
array<string|array>
setFallback() ¶ public
setFallback(string|null $fallback): void
Sets the fallback package name.
Parameters
-
string|null
$fallback The fallback package name.
Returns
void
setFormatter() ¶ public
setFormatter(string $formatter): void
Sets the formatter name for this package.
Parameters
-
string
$formatter The formatter name for this package.
Returns
void
setMessages() ¶ public
setMessages(array<string|array> $messages): void
Sets the messages for this package.
Parameters
-
array<string|array>
$messages The messages for this package.
Returns
void