← Roadmap

EffectiveLocale

Locale and config

Why

Texts in code are "we will translate later" forever. The framework gives one object per plugin that copies yml from the jar into the plugin folder, takes the language from the shared EffectiveSpigot config and returns a string or an Adventure component.

EffectiveConfig is the same scheme for config.yml: init() copies the default on first run, then typed getters.

Minimal example

Locale
// src/main/resources/languages/ru.yml
// items:
//   ruby:
//     name: "<red>Рубин"
//     given: "&aВыдано %d шт."

object MyLocale : EffectiveLocale() {
    override fun getPlugin() = MyPlugin.instance
}

meta.displayName(MyLocale.getComponent("items.ruby.name"))
player.sendMessage(MyLocale.getComponent("items.ruby.given", 3))
Config
object MyConfig : EffectiveConfig() {
    override fun getInstance() = MyPlugin.instance
    override fun getFileName() = "config.yml"

    fun getArenaSize() = getInt("arena.size", 32)
}

override fun onEnable() {
    MyConfig.init()
}

What to override

  • getPlugin() *
    EffectiveLocale: whose jar and folder
  • getInstance() *
    EffectiveConfig: owning plugin
  • getFileName() *
    EffectiveConfig: file name

* required

Pitfalls

  • saveResource does not overwrite an existing yml — after changing a locale in the jar, delete the old file in plugins/<Plugin>/languages.
  • A string with & or § codes goes through the legacy parser, otherwise MiniMessage. They cannot be mixed in one string.
  • One language per server — from the EffectiveSpigot config, not yours.