Languagy [1.9-1.16] 2.0.3

Easily support a player's selected language

  1. SamB440
    Native Minecraft Version:
    1.13
    Tested Minecraft Versions:
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    • 1.14
    • 1.15
    • 1.16
    Source Code:
    https://gitlab.com/SamB440/languagy
    Languages Supported:
    Nearly all of them
    What is Languagy?
    Languagy is a Spigot API for providing player-individual languages for plugins. It supports over 90 languages.

    Developers
    When your plugin requests a message for a player, their locale is detected and the API will get your plugin's appropiate language file with the string needed.

    Server Owners
    Simply place the .jar on your plugins folder. Any plugin that supports Languagy will automatically translate for you, however you need to translate the language files yourself if the plugin doesn’t natively support it. See the Usage section below for more information.

    Once translated, change your Minecraft language to the language you want to translate to check that it works correctly.

    In-game editor
    You can easily edit all translations of any plugin using the command /lgy edit which will bring up a GUI.

    No lag
    Languagy is designed to have minimal impact on your server performance. It will likely never show up in your timings.

    Automatically sync translations
    Languagy will automatically download custom translations for a plugin when a change is detected, keeping any translation files up-to-date.

    Java 8+ Support & 1.9 - 1.16 Support
    Languagy supports all Java versions 8 or over. It also supports all Spigot versions 1.9+. Languagy will always aim to support the latest version whilst attempting to maintain backwards compatibility and plugin quality.​

    Why Languagy?
    Supporting multiple languages is rare in servers these days. When it does happen, this is done through obscure GUIs. Languagy makes this simple by automating the process to have no impact on your users, improving the quality of your server. It is simple to use and can be integrated into plugins easily and cleanly, including via gradle/maven shading.

    Usage
    Simply drag and drop the plugin into your Plugins folder. Languages can be disabled/enabled in config.yml. Run /lgy test in-game with the language English, then run with Dutch to make sure the plugin is working correctly.

    You can also edit in-game using /lgy edit.

    Supported Languages
    You can view a list of the supported languages here. Different forms of languages have been added for the sake of different grammar and spellings.

    Supported plugins
    Want your plugin here? PM me, post in the discussion, or leave a review.
    Shading
    As of v2.0.2, Languagy is now shadeable. To shade Languagy, use the following gradle configuration (or make the Maven equivalent, see https://jitpack.io/#com.gitlab.samb440/languagy/master-SNAPSHOT):
    Code (Text):
    plugins {
        id 'com.github.johnrengelman.shadow' version '5.2.0'
        id 'java'
    }

    repositories {
      maven { url 'https://jitpack.io' }
    }

    dependencies {
      implementation 'com.gitlab.samb440:languagy:2.0.3-RELEASE'
    }

    shadowJar {
        relocate 'net.islandearth.languagy', 'YOUR_PACKAGE_HERE.languagy'
    }
    Then add Languagy to your soft-depend in plugin.yml.
    API Usage - updated for v2
    Firstly create a default language file that the API will fallback to when the player's language is not found/supported. Generally, en_gb should be preferred.

    Your language files should be located in a single folder, preferably named "lang". You can then simply use
    Code (Java):
    saveResource("lang/en_gb.yml")
    . I have made a complete class of utilising Languagy that you may benefit from: https://gitlab.com/SamB440/rpgregio...arth/rpgregions/translation/Translations.java

    Finally, we need to let the main class implement LanguagyPluginHook. The method provided will be called when the translator has been initiated and you can access it then.

    Now on your translator field, apply the LanguagyImplementation annotation like so:
    Code (Java):

    @LanguagyImplementation(Language.ENGLISH)
    private Translator translator;
     
    If you shade Languagy:
    In your onEnable, add the following call:
    Code (Text):
    hook(this);

    Now you can reference this translator from other classes using Plugin#getTranslator.

    Further API
    Translator#setDisplay(Material) - sets display material in /lgy edit
    LanguagyAPI#getLanguagy - class for API usage
    Translator#getOptions - extra options for translating

    Events:
    • PlayerTranslateEvent - called when message is translated
    • PluginHookEvent - called when a plugin is hooked
    Using the TranslatorOptions class
    The TranslatorOptions class currently offers one functionality: to automatically download custom translations for a plugin when a change is detected, keeping any translation files up-to-date.

    To use it, there are two methods:
    • externalDirectory - searches the entire directory of a url for custom language files
    • externalFile - downloads a single, specified file from a url
    Each method takes a string as a parameter - this is your url to the directory, for example: https://www.islandearth.net/plugins/mcrealistic/lang/. Languagy will then append the file to the end of the url like so: https://www.islandearth.net/plugins/mcrealistic/lang/cs_cz.yml. If it doesn't exist on the url, or is not a valid file, it won't be downloaded.

    #externalFile requires a Language parameter, in order to know what it is downloading.

    Languagy will only download .yml files, and will only do so if a change is detected (using sha1 hash).​

    Getting a string for a player

    Getting a string for a player is simple;
    Code (Java):
    plugin.getTranslator().getTranslationFor(arg0, arg1);
    arg0 is your player, and arg1 is the path to the string in your language file, just like configuration files!
    There is no need to translate chat colours, the API does that for you.

    You can also get a string list using #getTranslationListFor.

    Bug Reporting/Support/Questions
    Issues should be filed by hitting the issues tab in gitlab. Please make sure you search your issue before opening a new ticket.

    All opened tickets that are bug reports require a debug log that includes logs of the issue in question.

    FAQ:

    • Do I need to restart/reload to update messages? No, the file is kept updated so you never need to restart/reload, you can change it whilst the server is running. It may take up to 5 minutes to update, however.
    • Performance? I run Languagy on several servers both big (40+) and small (0-10) and have never had issues with Languagy performance. Languagy also works asynchronously (in part) if you use Paper.

    Metrics
    Languagy uses bStats to collect statistics on the usage of the plugin. I would appreciate you not disabling this as it keeps me motivated and helps to improve the plugin.

    Compiling
    Languagy builds on Java JDK 1.8 and uses Gradle to manage dependencies.

    Via bash:
    Code (Text):
    cd Languagy
    ./gradlew build
    [​IMG]
    Robiahn and Joedon like this.

Recent Updates

  1. Languagy 2.0.3
  2. Languagy 2.0.2
  3. Languagy 2.0.1

Recent Reviews

  1. Muron_Eth
    Muron_Eth
    5/5,
    Version: 2.0.3
    Pretty great!
    It helps me a lot...
    Thank u lol~
    ================================
    1. SamB440
      Author's Response
      Thanks for the review.
  2. xuanzhou
    xuanzhou
    5/5,
    Version: 2.0.0
    Fantastic API!Can I repost it to mcbbs(The biggest forum in China)?I'll let more chinese user know your project.Thank you
    1. SamB440
      Author's Response
      Yes but all downloads must only link to this page
  3. dinoboss2001
    dinoboss2001
    5/5,
    Version: 1.2.0
    me gusto el plugin nos harías un tutorial explicando como configurarlo y hacerlo funcionar al 100%
    1. SamB440
      Author's Response
      This is more of an API than a plugin; I’m not really sure how to improve the documentation further. Most of what you need is on the front page, and a seperate wiki is being worked on :)
  4. PandaDuck
    PandaDuck
    5/5,
    Version: 1.0.1
    Great work! Author is just a man! What a cool guy :) ……………………………………………………………… 80
    1. SamB440
      Author's Response
      Glad I could help!
  5. Ti2Ga
    Ti2Ga
    5/5,
    Version: 1.0.0
    niiiiiiiiiiiiiiice. verrrrrrrrryyyyyyyyyynnnnnniiiiiiicccceeeeee (80 Characters)
    1. SamB440
      Author's Response
      Thanks for the review! Hope you make your server / plugins more multilingual!