LTS API

Get the player language

With the LTS API, you can get the player language to translate your message in it.

Lang lang = player.getLang();

You can also change the player language.

player.setLang(Lang.EN);

See also: Lang.java on GitHub, Player API

Register your translated messages

When the plugin is enabling, you have to register the messages you what to send to the player.

See this example where we register a welcome message:

public void onEnable() {
  // ...
  // Other actions of your onEnable()
  // ...

  Translater.set("welcome_message",
    new Translation(
      new TranslatedMsg(Lang.EN, "Welcome to my server!"),
      new TranslatedMsg(Lang.FR, "Bienvenue sur mon serveur !")
    )
  );
}

Send it to your players

When the plugin is enabling, you have to register the messages you what to send to the player.

See this example where we send the previous welcome message to the player when it joins the server:

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
  Player player = event.getPlayer();
  ZabriPlayer zp = CraftSearch.getInstance().getPlayer(player.getUniqueId());
  player.sendMessage(Translater.get("welcome_message", zp.getLang()));
}