Advanced Multi Language 1.10.4


Tested Minecraft Versions:
  • 1.8
  • 1.9
  • 1.10
  • 1.11
  • 1.12
Source Code:
https://github.com/smessie/AdvancedMultiLanguage
Contributors:
smessie
Welcome to the official spigot page of this plugin: Advanced Multi Language!

This plugin is created with spigot1.8.3 but it works with 1.8.x and 1.9.x and up.
Support for BungeeCord since version 1.4!


What does this plugin?

This plugin let your players select their language with a simple command, yes simple. Just the translation of "language" in their own language ;)
But, yeah ... if they have set their language and then?
Well, then you could send players messages from the server in their selected language with the easy to use API.
With this API developers could get the language of the player and send them a message in their language! :D

If you are a server owner
Hi there ;)
You only needs to put this plugin in your plugins folder and restart the server so the plugin is loaded.
Attention: you must create the database mannualy if you want to use MySQL! The table is going to create automatically :)
Let the players set their language with one of the commands.
You can choose between MySQL or flatfile saving in the config file.
Every language can be disabled in het config.yml if you want that players can't choose that language.
I recommend to use the MySQL if you use BungeeCord so the data is the same accross your network.

Commands
/language <language>
/langue <langue>
/sprache <sprache>
/taal <taal>
/idioma <idioma>
/язык <язык>
/valoda <valoda>

Supported languages
Current supported languages:
  • English: EN
  • French: FR
  • German: DE
  • Dutch: NL
  • Spanish: ES
  • Russian: RU
  • Latvian: LV
  • Italian: IT
  • Bulgarian: BU
  • Hungarian: HU
  • Dansk: DK
  • Chinese: CHS
  • More coming soon*


Developers & API
Its just easy to get the language of the player.
All you need to do is using this code:
Code (Text):
String language = AdvancedMultiLanguageAPI.getLanguageOfUuid(String uuid);
String uuid = the UUID of the player .toString() so of you have a player you could use player.getUniqueId().toString();
You recieve the language of a player in an abbreviation.
The abbreviations are:
  • For English: EN
  • For French: FR
  • For German: DE
  • For Dutch: NL
  • For Spanish: ES
  • For Russian: RU
  • For Latvian: LV
  • For Italian: IT
  • For Bulgarian: BU
  • For Hungarian: HU
  • For Dansk: DK
  • For Chinese: CHS
  • More coming soon*
Once you retrieved the language you can get the translated message par example of a file under /plugins/<plugin>/messages with a file named EN.yml
This is all your choise. :)

Here you have a comprehensively example with a joinEvent
Code (Text):
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {

        Player player = event.getPlayer();
        String uuid = player.getUniqueId().toString();
        String language = AdvancedMultiLanguage.getLanguageOfUuid(uuid);

        //Check if the language is English
        if(language.equalsIgnoreCase("EN")) {
            player.sendMessage(ChatColor.YELLOW + "Welcome to the server " + player.getName() + "!");
        }

        //Check if the language is Dutch
        if(language.equalsIgnoreCase("NL")) {
            player.sendMessage(ChatColor.YELLOW + "Welkom op de server " + player.getName() + "!");
        }

        //Check if the language is French
        if(language.equalsIgnoreCase("FR")) {
            player.sendMessage(ChatColor.YELLOW + "Bienvenue sur le serveur " + player.getName() + "!");
        }
    }
Or the New method in the API.
Get the translated message located in plugins\<your plugin>\messages\EN.yml
EN is the language such as EN.yml, NL.yml, DE.yml, FR.yml, ...
The path is the path in the config, example: "usage" or "messages.usage".

An example to use here:
Code (Text):

                Player p = (Player) sender;
                String message = AdvancedMultiLanguageAPI.getMessage(p.getUniqueId().toString(), "usage", Main.plugin.getName());
                sender.sendMessage(message);
 
If a player changes his language will an event being called.
You can listen it with the following code as example.
Code (Text):
@EventHandler
public void onPlayerChangeLanguage(LanguageChangeEvent event) {
// you can get the player that changes his language
Player player = event.getPlayer();

// you can get the language that the player is changing to
Language language = event.getLanguage();

// you can cancel the event
event.setCancelled(true);

}
@x9nico made a nice tutorial about how to use the API of this plugin.
The video is French sproken. Thanks to him for creating it :D




*New languages
Please, send me a PM to suggest new languages.
What must be in your PM:

  1. Translation of "Usage: /language <language>"
  2. Translation of "This language is disabled."
  3. Name of your language in your own language.
  4. Translation of the name in English.
  5. Translation of "Your language is set to English"
  6. Translation of "Only ingame players can set their language."
  7. The abbreviation of your language
  8. Translation of ""Language English not found."
  9. Translation of "Attention! You may not speak English in the chat."
Example for a Dutch suggestion:
Default Config
http://pastebin.com/zLkhLBEb

ToDo
  • Adding support for BungeeCord Done! (since version 1.4)
  • Adding more languages
  • Adding messages.yml
  • ... say me ...

Plugins using this API

Donations
If you like my work and would support me and motivate me to make more plugins you could donate to me (I really appreciate that!)
[​IMG]

About me
I'm the proud developer of this resource and I hope other developers shall use the API in their plugins.
You can follow me on twitter: www.twitter.com/smessie_ for updates and more.
I have an own MC network, it's Dutch so if you are a Dutch speaker or you like Dutch people you may join this fancy server on peekewee.dyndns.org :eek: