message library
🌐 Jetleaf Internationalization (i18n) & Message Subsystem
This library provides the message resolution and internationalization (i18n) infrastructure for Jetleaf applications, enabling parameter-driven localized text, message bundles, and hierarchical fallback resolution.
📦 Exports Categorization
🗣️ Message Sources
- MessageSource — strategy interface for resolving messages, supporting parameterized arguments and internationalization.
- AbstractMessageSource — base implementation handling parameter interpolation and hierarchical parent delegation.
- ConfigurableMessageSource — mutable message source allowing runtime message registration.
- MessageSourceLoader — utility for loading message bundles from property files or JSON assets.
🎯 Usage Example: Localized Message Resolution
import 'package:jetleaf_core/message.dart';
void main() {
final source = ConfigurableMessageSource();
source.addMessage('user.welcome', 'en', 'Welcome back, {0}!');
source.addMessage('user.welcome', 'fr', 'Bienvenue, {0}!');
final enMsg = source.getMessage('user.welcome', args: ['Alice'], locale: 'en');
final frMsg = source.getMessage('user.welcome', args: ['Alice'], locale: 'fr');
print(enMsg); // Welcome back, Alice!
print(frMsg); // Bienvenue, Alice!
}
Classes
- AbstractMessageSource
- Base implementation of MessageSource providing common functionality.
- ConfigurableMessageSource
- Main implementation of MessageSource that supports loading messages from multiple resources and formats.
- MessageSource
- Interface for resolving messages, with support for parameterization and internationalization.
- MessageSourceLoader
- Interface for loading messages from different resource formats.