-
Notifications
You must be signed in to change notification settings - Fork 0
Api: MessageRegistry
Adrian edited this page Feb 28, 2024
·
4 revisions
-
The locale to use if none is provided to
string $defaultLocale
message()
ormessageFrom()
. Note, no validation is performed on the value set.
-
public static message( string $key, array $context, string $locale = null, string $group = "" ) : ? string
Looks up and formats the message identified by key, using the given locale and context.
-
parameters:
- string
$key
: Message identifier. This is a dot-delimited path for the message format to look up. - array
$context
: Formatting context, in key:value format. Non-scalar values will be encoded if possible. - ? string
$locale
: Target message locale - string
$group
: The bundle group name to look up the message format in
- string
-
Throws
MessageException
MessageError::FormatFailed: On failure -
Returns
string
|null
: Formatted message on success; or null if message format is not found
-
parameters:
-
public static message( ResourceBundle $messages, string $key, array $context, string $locale = null ) : ? string
Looks up and formats the message identified by key, using the given locale and context, from the given bundle of messages.
This method is the same as
::message()
, but does not look in the message registry; it only uses the given bundle.-
parameters:
- ResourceBundle
$messages
: The messages bundle to look up format from - string
$key
: Message identifier. This is a dot-delimited path for the message format to look up. - array
$context
: Formatting context, in key:value format. Non-scalar values will be encoded if possible. - ? string
$locale
: Target message locale
- ResourceBundle
-
Throws
MessageException
MessageError::FormatFailed: On failure -
Returns
string
|null
: Formatted message on success; or null if message format is not found
-
parameters:
-
public static register( ResourceBundle $messages, string $group = "" ) : void
Adds a resource bundle to the registry.
-
parameters:
- ResourceBundle
$messages
: Message format patterns - string
$group
: The group name to register the bundle to. if omitted, uses the default group.
- ResourceBundle
-
parameters:
-
public static register( ResourceBundle $messages, string $group = "" ) : void
Removes a resource bundle from the registry.
-
parameters:
- ResourceBundle
$messages
: Message format patterns - string
$group
: The group name to unregister the bundle from. if omitted, uses the default group.
- ResourceBundle
-
parameters: