Implemented by a bean that wants the translated messages handed to it through a method call.
The usual way is to inject MessageSource through the constructor;
this callback exists for beans that cannot. What it receives is the
context, which looks messages up in the messageSource bean.
// Translates labels for the user's locale.
@Component()
class Labels implements MessageSourceAware {
late MessageSource messages;
@override
void setMessageSource(MessageSource messageSource) =>
messages = messageSource;
}
Spring (Java):
@Component
class Labels implements MessageSourceAware {
public void setMessageSource(MessageSource messageSource) { ... }
}
- Implemented types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setMessageSource(
MessageSource messageSource) → void - Receives the context, which is a message source; called once, after injection and before the init callbacks.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited