Language Utils

This project is inactive and its default file will likely not work with the most recent version of Minecraft. The author may have abandoned it, or it may have outlived its usefulness.

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 language entries.

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

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

Resources

Installation

If you are a server owner, just drop the plugin into your plugins/ folder. This plugin itself does not have any functionalities 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.

repositories { maven { url 'https://raw.github.com/MascusJeoraly/LanguageUtils/mvn-repo/' } } dependencies { compile group: 'com.meowj', name: 'LangUtils', version: '1.6.0' // Please check the latest version }

Maven: add the following to your pom.xml

``` <repositories> <repository> <id>lang-utils-repo</id> <url>https://raw.github.com/MascusJeoraly/LanguageUtils/mvn-repo/&lt;/url&gt; </repository> </repository>

<dependencies> <dependency> <groupId>com.meowj</groupId> <artifactId>LangUtils</artifactId> <version>1.6.0</version> </dependency> </dependencies> ```

Usage

Items

  1. Get the display name of an item(including customized name): LanguageHelper.getItemDisplayName(itemStack, locale); LanguageHelper.getItemDisplayName(itemStack, player);

For example, if you want to get the English name of an item: LanguageHelper.getItemDisplayName(itemStack, "en_US");

  1. Get the localized name of an item: LanguageHelper.getItemName(itemStack, locale); LanguageHelper.getItemName(itemStack, player);

  2. Get the unlocalized name of an item LanguageHelper.getItemUnlocalizedName(itemStack);

Entities

  1. Get the unlocalized name of an entity LanguageHelper.getEntityUnlocalizedName(entity); LanguageHelper.getEntityUnlocalizedName(entityType);

  2. Get the localized name of an entity 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) LanguageHelper.getEntityDisplayName(entity, locale); LanguageHelper.getEntityDisplayName(entity, player);

Ofc, if you only want the English name of an entity, you can just use entity.getName();

Enchantments

  1. Get the unlocalized name of an enchantment LanguageHelper.getEnchantmentUnlocalizedName(enchantment);

  2. Get the name of an enchantment LanguageHelper.getEnchantmentName(enchantment, player); LanguageHelper.getEnchantmentName(enchantment, locale);

  3. Get the full name of an enchantment(including its level) 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>.

Enchantment levels

  1. Get the unlocalized name of an enchantment level LanguageHelper.getEnchantmentLevelUnlocalizedName(level);

  2. Get the name of an enchantment level LanguageHelper.getEnchantmentLevelName(level, player); LanguageHelper.getEnchantmentLevelName(level, locale);

Misc

  1. Translate an unlocalized name LanguageHelper.translateToLocal(unlocalizedName, locale);

  2. Get the language a player is using LocaleHelper.getPlayerLanguage(player);

  3. Add/Replace a language entry LanguageRegistry.INSTANCE.registerEntry(lang, unlocalizedName, localizedName); You can see this demo plugin for more details.

Configuration

FallbackLanguage=en_US

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+)

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    101751
  • Created
    Aug 16, 2016
  • Last Released File
    Aug 16, 2016
  • Total Downloads
    408
  • License

Categories

Members