-
Notifications
You must be signed in to change notification settings - Fork 1
I18n How to Use
The I18n API was designed to be pretty easy to use and this part of the framework is heavily developed and is heavily integrated with LCF you can use it practically everywhere you want to.
It supports:
- Returning keys from any command.
- Descriptions
- Syntax
First of all you need to initialize I18n you can do it by scanning normally using scanner that is scanning whole package Scanner.scan()
by placing this code snippet in onEnable BEFORE initializing any of the commands
Use if you don't use scan
Scanner.initPluginI18n(plugin)
Below you have an image representing on how you need to place your files in order for I18n to automatically load them
File names are important if you want for example Italian translation you just use proper code at the end for example: messages-ita.properties
You can have multiple translations of various languages in one plugin
By default I18n tries to read default english file if it encounters problems with finding key
import org.bukkit.entity.Player
class SomeCommand {
fun run(player: Player): String {
return "<run-message>"
}
}
For given messages-{locale}.properties
run-message=Yay you ran command!
Will output to player the following: "Yay you ran command!"
val messsageKeyPath = "something"
val valueMessage = "lol"
val tagResolverBuilder = TagResolver.builder()
// Resolve <something> to lol
tagResolverBuilder.resolver(PlaceHolder(messageKeyPath, valueMessage))
val message = I18nMessage(myPlugin, messageKeyPath, tagResolverBuilder.build())
message.send(playerISendTo)
// or if you want to get component
val componentMsg = message.getI18nResponse()
- Maven installation
- Using in java
- Initializing commands
- I18n
- Annotations
- Additional
- Errors