Actions & Messages
Everything the server says to a person is a MessageText: a key, positional arguments, and, where needed, the module whose bundle holds the key. Never prose. The server resolves it in the request's language before the response leaves, so the client shows finished text, and the same message reads in German for one user and in English for the next.
use LaravelUi5\Sdk\Action\Messages\MessageText;
MessageText::of('messages.period.alreadyClosed', [$period->name]);# your app's i18n/i18n.properties, and i18n_de.properties beside it
messages.period.alreadyClosed=The period {0} is already closed.Arguments are positional ({0}, {1}), as UI5's getText() expects, and scalar. Mind the apostrophe in a value that carries one.
Where it is used
| Who says it | How | Page |
|---|---|---|
| An action's handler | $transaction->commit(…), rollback(…), info(), warning(), error(), success() | Mutating Actions |
| An intent | IntentResult::deny(…), message(…) | Intent Dispatch |
| A unit of work on the console | its Outcome; the messages go to the terminal | Units of Work |
There is no string variant anywhere. An exception you turn into a refusal gets a key of its own.
Whose bundle
A key is looked up in one module's bundle. Which one:
from()names it explicitly:MessageText::of('messages.user.locked')->from(UsersApp::NAMESPACE).- Without
from(), the issuer decides. An action's message is read from the bundle of the app the action belongs to, so a handler rarely needsfrom(). An intent's reason is read from the SDK's library,com.laravelui5.sdk, where the SDK keeps its own reasons (sdk.intent.deny.*); an intent of yours names its app withfrom().
A key that no bundle carries shows as the key. That is a gap in a bundle, not an error: it is what you see in the browser when a key was forgotten.
What the client receives
An action's response carries each message with its key, its params and the resolved text. The client shows the text as it is; the key is there for tests and for support. The headline of a commit() becomes a toast; the headline of a rollback() opens the message dialog.
In the business log
A message a unit of work logs on purpose is stored as key, arguments and bundle, never as text, in sdk_business_log (The Audit). It is read in the reader's language, so a log written for a German user reads in English for the support engineer.