MessageProviderDefault

An abstract base class implementing the IMessageProvider interface for creating localized message systems.

This class is intended to handle the localization of messages grouped by language settings and provides multiple strategies for retrieving context-aware localized messages, including:

  • Messages with sequential arguments.

  • Messages using placeholder-based maps.

  • Messages generated based on intermediate types and custom transformations.

The output type of localized messages is determined by the generic type parameter C.

Parameters

P

Self-referenced generic type used for type-safe association within implementations.

C

The type of the final localized message output (e.g., string, text component).

Constructors

Link copied to clipboard
constructor(clazz: Class<C>)

Properties

Link copied to clipboard
val clazz: Class<C>

The class type of the final output used during message conversion.

Link copied to clipboard

Retrieves the LangMan instance.

Functions

Link copied to clipboard
abstract fun getLanguage(): String

Retrieves the language code associated with this provider.

Link copied to clipboard
open override fun getMessage(key: MessageKey<*, *>, vararg args: Any): C

Retrieves a formatted localized message using sequential arguments.

open override fun <K, V> getMessage(key: MessageKey<*, *>, argsComplete: Map<K, V>): C

Retrieves a formatted localized message using a map of named arguments.

open override fun <T, K, V> getMessage(key: MessageKey<*, *>, intermediate: T, transform: (T) -> Map<K, V>): C

Retrieves a formatted localized message using an intermediate data type.

Link copied to clipboard
inline fun <G : Any> getMsg(key: MessageKey<*, *>, argsComplete: Map<String, G> = emptyMap()): C

Retrieves a localized message of type G, applies placeholder replacement, and then converts it into the default class type C.

Link copied to clipboard
inline fun <C : Any> getMsgWithOther(key: MessageKey<*, *>, argsComplete: Map<String, C> = emptyMap()): C

Retrieves a localized message of type C based on the specified key, applies placeholder replacement using argsComplete, and converts the processed message into the requested type.

Link copied to clipboard
open override fun getRawMessage(key: MessageKey<*, *>): String

Retrieves the raw message string for the provided key without formatting.

Link copied to clipboard
open override fun hasMessage(key: MessageKey<*, *>): Boolean

Checks if a localized message exists for the given key.