ColosseumI18nManager

A class that manages a plugin's i18n. This handles static and dynamic languages. Static languages are languages that never change and are usually loaded from the plugin jar. Dynamic languages are languages that can change at runtime and are usually loaded from a database or file. The plugin will cache dynamic languages to prevent unnecessary loading, and will reload them when invalidated. When a message is requested, the plugin will first check the cached dynamic languages, then the dynamic languages, and finally the static languages. If the get method is called with a CommandSender, the plugin will use the forced language if it is set, otherwise it will use the player's locale. If the player's locale is not found, the default language will be used. If the command sender is not a player, the default language will be used.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The default language.

Link copied to clipboard

The language to force for players.

Functions

Link copied to clipboard
operator fun get(lang: String): Map<String, String>?

Gets the language map for the specified language.

operator fun get(lang: String, key: String): String?

Gets a message from the language file, for a specific language.

operator fun get(lang: String, key: String, vararg placeholders: Pair<String, String>): String?

Gets a message from the language file, for a specific language. Placeholders in the message will be replaced with the specified values.

operator fun get(commandSender: CommandSender, key: String, vararg placeholders: Pair<String, String>): String?

Gets a message from the language file, for a specific language. Placeholders in the message will be replaced with the specified values. If the command sender is a player, the message will be formatted based on the player's locale, else the default language will be used.

Link copied to clipboard
fun getLocale(commandSender: CommandSender): String

Gets the appropriate locale for the command sender. If the command sender is a player, the forced language will be used if set and available, otherwise the player's locale will be used if available, else the default language will be used.

Link copied to clipboard

Checks if the specified language is available.

Link copied to clipboard

Invalidates the cached dynamic languages. This should be called when a dynamic language is updated. This will force the plugin to reload the dynamic language.