[1.7.x-1.12]Language Utils 1.9

A simple Bukkit/Spigot language API

  1. Meow-J
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    Source Code:
    https://github.com/MascusJeoraly/LanguageUtils
    Contributors:
    Meow J, hexosse, Raspen0
    Introduction
    It was always a problem to get the localized name of an item(afaik), so Language Utils came out to solve this issue. This API only provides names for vanilla strings.

    In the following updates, I also add the support for entities, enchantments, and enchantment levels.

    The major version is for Spigot/Bukkit 1.12. If you are using Spigot/Bukkit 1.7.10, 1.8.9, 1.9.4, 1.10.x, or 1.11.x, use this, this, this, this, or this instead.

    Update: You can use the latest 1.7.10 version of this API on Cauldron/KCauldron servers now. You can download the latest 1.7.10 version here. Again, the API only supports vanilla items/entities(Though it will return the material name if the item is not vanilla).

    Status: [​IMG]

    Resources

    Installation
    If you are a server owner, just drop the plugin into your plugins/ folder. This plugin itself does not have any functions and it may take 100-250 ms to load all the language files. If you want to customize the language entries, please read the README.txt inside plugins/LangUtils/lang/.

    If you are a developer, add the API to your build path. Additionally, if you are using Gradle or Maven:

    Gradle: add the following to your build.gradle
    Code (Text):
    repositories {
        maven {
            url 'https://raw.github.com/MascusJeoraly/LanguageUtils/mvn-repo/'
        }
    }
    dependencies {
        compile group: 'com.meowj', name: 'LangUtils', version: '1.9' // Please check the latest version
    }
    Maven: add the following to your pom.xml
    HTML:
    <repositories>
      <repository>
        <id>lang-utils-repo</id>
        <url>https://raw.github.com/MascusJeoraly/LanguageUtils/mvn-repo/</url>
      </repository>
    </repository>

    <dependencies>
      <dependency>
        <groupId>com.meowj</groupId>
        <artifactId>LangUtils</artifactId>
        <!--Please check the latest version -->
        <version>1.9</version>
      </dependency>
    </dependencies>
    Usage
    1. Get the display name of an item(including customized name):
    Code (Text):
    LanguageHelper.getItemDisplayName(itemStack, locale);
    LanguageHelper.getItemDisplayName(itemStack, player);
    For example, if you want to get the English name of an item:
    Code (Text):
    LanguageHelper.getItemDisplayName(itemStack, "en_us");
    2. Get the localized name of an item:
    Code (Text):
    LanguageHelper.getItemName(itemStack, locale);
    LanguageHelper.getItemName(itemStack, player);
    3. Get the unlocalized name of an item
    Code (Text):
    LanguageHelper.getItemUnlocalizedName(itemStack);
    1. Get the unlocalized name of an entity
    Code (Text):
    LanguageHelper.getEntityUnlocalizedName(entity);
    LanguageHelper.getEntityUnlocalizedName(entityType);
    2. Get the localized name of an entity
    Code (Text):
    LanguageHelper.getEntityName(entity, locale);
    LanguageHelper.getEntityName(entity, player);
    LanguageHelper.getEntityName(entityType, locale);
    LanguageHelper.getEntityName(entityType, player);
    3. Get the display name of an entity(including customized name)
    Code (Text):
    LanguageHelper.getEntityDisplayName(entity, locale);
    LanguageHelper.getEntityDisplayName(entity, player);
    Ofc, if you only want the English name of an entity, you can just use
    Code (Text):
    entity.getName();
    1. Get the unlocalized name of an enchantment
    Code (Text):
    LanguageHelper.getEnchantmentUnlocalizedName(enchantment);
    2. Get the name of an enchantment
    Code (Text):
    LanguageHelper.getEnchantmentName(enchantment, player);
    LanguageHelper.getEnchantmentName(enchantment, locale);
    3. Get the full name of an enchantment(including its level)
    Code (Text):
    LanguageHelper.getEnchantmentDisplayName(enchantment, level, player);
    LanguageHelper.getEnchantmentDisplayName(enchantment, level, locale);
    LanguageHelper.getEnchantmentDisplayName(entry, level, player);
    LanguageHelper.getEnchantmentDisplayName(entry, level, locale);
    where entry is Map.Entry<Enchantment, Integer>.
    1. Get the unlocalized name of an enchantment level
    Code (Text):
    LanguageHelper.getEnchantmentLevelUnlocalizedName(level);
    2. Get the name of an enchantment level
    Code (Text):
    LanguageHelper.getEnchantmentLevelName(level, player);
    LanguageHelper.getEnchantmentLevelName(level, locale);
    1. Translate an unlocalized name
    Code (Text):
    LanguageHelper.translateToLocal(unlocalizedName, locale);
    2. Get the language a player is using
    Code (Text):
    LocaleHelper.getPlayerLanguage(player);

    3. Add/Replace a language entry
    Code (Text):
    LanguageRegistry.INSTANCE.registerEntry(lang, unlocalizedName, localizedName);

    You can see this demo plugin for more details.

    Build
    This API uses Gradle to manage the source code. If you want to build the project your self, simply run
    Code (Text):
    gradle build
    or
    Code (Text):
    gradlew build
    if you don't have Gradle installed.

    Configuration

    Code (Text):

    # When a name in the language requested does not exist, the name will be retrieved in this language. The default fall back language is English.
    FallbackLanguage=en_us
    # If you want to enable the loading of a language, add it to the following list
    LoadLanguage= [en_us, zh_cn, zh_tw]
    # Or
    LoadLanguage:
    - en_us
    - zh_cn
    - zh_tw
    # If you want to load all the languages, add "all" to the list:
    LoadLanguage:
    - all
     

    Known Issues

    • Currently I'm using HashMap and Enum to organize languages(& items). And it may take 50-1000 μs to retrieve one item name.(may be longer) If you have more efficient ways to load or to lookup names, please let me know.
    • Support for items in mods(seems unneccessary in 1.8 and 1.9)
    GuillaumeVDN likes this.

Recent Reviews

  1. komiss77
    komiss77
    5/5,
    Version: 1.9
  2. gregman98.tw
    gregman98.tw
    4/5,
    Version: 1.9
    GitHub我已經發同一個問題了...
    是否將繼續更新到1.15以上?
    這個插件已經很久沒有看到再更新了,
    一些API並不受支持,希望有一日能看到作者繼續更新!
  3. Whiskey990
    Whiskey990
    3/5,
    Version: 1.9
    Last Update: v2.1.17-mc1.13.1 on 28 DEC 2018
    Link: https://github.com/NyaaCat/LanguageUtils/releases

    Update: Looks like this hasn't seen an update for ~10 months. Anyone tested to see if it attempts to work on 1.14.4?

    Review: I can't say much other than I used it in 1.12 as it was needed for some functionality of Boss Shop Pro which was much appreciated.
  4. HI_nnn950711
    HI_nnn950711
    5/5,
    Version: 1.9
  5. Command1
    Command1
    5/5,
    Version: 1.9
    It's a good plugin. Hope update to 1.13.2 and can continued update to 1.14 and after 1.14 version. Sorry, my english isn't good. I'n from Taiwan.
  6. RisingStarLuke
    RisingStarLuke
    4/5,
    Version: 1.9
    It does what it says, problem is it looks like it is inactive, and I'd love to see 1.13 support
  7. LogoCat
    LogoCat
    5/5,
    Version: 1.9
    Nice plugin. Hoping to see the 1.13 version coming out :) .
  8. RoyalScribblz
    RoyalScribblz
    5/5,
    Version: 1.9
    Great job! Less writing for me doing my chat plugin ............................
  9. hugogaymer
    hugogaymer
    4/5,
    Version: 1.9
    Seems great but it's not working for me, says You are holding item.swordIron.name :(
  10. jessefjxm
    jessefjxm
    5/5,
    Version: 1.8.1
    Great job, man! 这下翻译起来方便多了.

    蛋疼的字数要求。