I18N

class I18N(val plugin: Plugin, val dir: File, val fileValidator: (File) -> Boolean = { it.extension == "yml" || it.extension == "yaml" })

Internationalization (I18N) manager for Bukkit plugins.

This class handles loading and managing localized messages from YAML files. Each file represents a locale and contains key-value pairs for translations.

Parameters

plugin

The Bukkit plugin instance

dir

The directory containing locale files

fileValidator

A predicate to validate locale files (default: checks for .yml or .yaml extension)

Constructors

Link copied to clipboard
constructor(plugin: Plugin, dir: File, fileValidator: (File) -> Boolean = { it.extension == "yml" || it.extension == "yaml" })

Properties

Link copied to clipboard

The default locale to use when a translation is not found in the requested locale. Defaults to Locale.US (English - United States).

Link copied to clipboard
val dir: File
Link copied to clipboard
Link copied to clipboard
val plugin: Plugin

Functions

Link copied to clipboard

Loads all locale files from the configured directory.

Link copied to clipboard
fun saveDefaultLocaleFiles(resourcePath: String = "i18n", locales: List<String>, replace: Boolean = false)

Saves default locale files from the plugin's resources.

Link copied to clipboard
fun translate(locale: Locale, key: String, vararg args: Any): String?

Translates a message key for the specified locale.

fun translate(player: Player, key: String, vararg args: Any): String?

Translates a message key using the player's locale.