Chat Translator

2.8k Downloads

Chat Translator

Chat Translator

About

This plugin simply translates the chat between languages so any player can understand what any other player says.

How it works

The player sets their language, or it is set to the default language (set in the config) or detected automatically. This is then used by the plugin to use the Yandex translation API to translate the chat.

Requirements

You will need:

Will this break my chat plugins?

This plugin is designed to override the chat almost entirely, so it most likely will. HOWEVER there is an API which can be used by developers to use the power of the plugin's translation without overriding the chat. You can turn off chat translation in the config.

The API (For developers to read)

The API allows you to:

  • See a player's set language
  • Set a player's language
  • Show to players an inventory menu to let them set their own language
  • Detect what language some text is written in
  • Translate text between languages
  • Change between API_KEYs
  • Most useful of all, specify custom MessageHandlers to allow for custom chat formatting.
  • There is also the ability to make the plugin handle your own custom chat 'events' the same as it would handle bukkit chat events (Even if bukkit chat events are set to not be handled) - This allows you to use this with a custom channel-based chat plugin.

API usage

Full documentation coming soon
All of the API's methods can be accessed using the org.stormdev.chattranslator.api.TranslatorToolkit class.
For example:

//Translate some text
String foo = "The quick brown fox jumped over the lazy dog";
try {
	String translated = TranslatorToolkit.getToolkit()
			.translate(Lang.ENGLISH, Lang.DUTCH, foo);
        System.out.println(translated);
} catch (Exception e) {
	//Something went wrong
	e.printStackTrace();
}

Supported Languages

There are currently 40 supported languages, including all the main ones. If Yandex add support for other languages, I will add those too. For a complete list of supported languages look at the ones available on https://translate.yandex.com/!

Commands & Permissions

CommandAliasesPermissionFunction
/lang/language, /setlang, /setlanguagechattranslator.setlanguageShows the player a GUI (Item menu) to select their language
/lang <en/fr/de/..>/language <...>, /setlang <...>, /setlanguage <...>chattranslator.setlanguageSets the player's language to the one specified
/lang <English/French/German>/language <...>, /setlang <...>, /setlanguage <...>chattranslator.setlanguageSets the player's language to the one specified