-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ae96cb
commit 9cf0eac
Showing
4 changed files
with
139 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package xyz.xasmc.hashbook.util | ||
|
||
import org.bukkit.Material | ||
import org.bukkit.configuration.file.YamlConfiguration | ||
import org.bukkit.enchantments.Enchantment | ||
import org.bukkit.inventory.meta.BookMeta | ||
import org.bukkit.inventory.meta.BookMeta.Generation.* | ||
import java.io.File | ||
|
||
object I18nUtil { | ||
private lateinit var config: YamlConfiguration | ||
|
||
fun loadTranslate(path: File) { | ||
config = YamlConfiguration.loadConfiguration(path) | ||
} | ||
|
||
fun translate(generation: BookMeta.Generation?): String { | ||
return when (generation) { | ||
ORIGINAL -> getTranslate("book.generation.0") | ||
COPY_OF_ORIGINAL -> getTranslate("book.generation.1") | ||
COPY_OF_COPY -> getTranslate("book.generation.2") | ||
TATTERED -> getTranslate("book.generation.3") | ||
null -> getTranslate("book.generation.0") | ||
} | ||
} | ||
|
||
fun translate(type: Material): String { | ||
val key = type.itemTranslationKey | ||
return if (key != null) getTranslate(key) else type.name.lowercase() | ||
} | ||
|
||
fun translate(enchantment: Enchantment, level: Int): String { | ||
val name = getTranslate(enchantment.translationKey()) | ||
val levelStr = if (level <= 10) getTranslate("enchantment.level.$level") else level.toString() | ||
return "$name $levelStr" | ||
} | ||
|
||
fun getTranslate(key: String): String { | ||
return config.getString(key) ?: key | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
item: | ||
minecraft: | ||
book: "书" | ||
enchanted_book: "<yellow>附魔书" | ||
knowledge_book: "<light_purple>知识之书" | ||
written_book: "成书" | ||
writable_book: "书与笔" | ||
|
||
book: | ||
byAuthor: "%s 著" | ||
generation: | ||
"0": "原稿" | ||
"1": "原稿的副本" | ||
"2": "副本的副本" | ||
"3": "破烂不堪" | ||
|
||
enchantment: | ||
level: | ||
"1": "I" | ||
"2": "II" | ||
"3": "III" | ||
"4": "IV" | ||
"5": "V" | ||
"6": "VI" | ||
"7": "VII" | ||
"8": "VIII" | ||
"9": "IX" | ||
"10": "X" | ||
minecraft: | ||
aqua_affinity: "水下速掘" | ||
bane_of_arthropods: "节肢杀手" | ||
binding_curse: "绑定诅咒" | ||
blast_protection: "爆炸保护" | ||
breach: "破甲" | ||
channeling: "引雷" | ||
density: "致密" | ||
depth_strider: "深海探索者" | ||
efficiency: "效率" | ||
feather_falling: "摔落缓冲" | ||
fire_aspect: "火焰附加" | ||
fire_protection: "火焰保护" | ||
flame: "火矢" | ||
fortune: "时运" | ||
frost_walker: "冰霜行者" | ||
impaling: "穿刺" | ||
infinity: "无限" | ||
knockback: "击退" | ||
looting: "抢夺" | ||
loyalty: "忠诚" | ||
luck_of_the_sea: "海之眷顾" | ||
lure: "饵钓" | ||
mending: "经验修补" | ||
multishot: "多重射击" | ||
piercing: "穿透" | ||
power: "力量" | ||
projectile_protection: "弹射物保护" | ||
protection: "保护" | ||
punch: "冲击" | ||
quick_charge: "快速装填" | ||
respiration: "水下呼吸" | ||
riptide: "激流" | ||
sharpness: "锋利" | ||
silk_touch: "精准采集" | ||
smite: "亡灵杀手" | ||
soul_speed: "灵魂疾行" | ||
sweeping: "横扫之刃" | ||
sweeping_edge: "横扫之刃" | ||
swift_sneak: "迅捷潜行" | ||
thorns: "荆棘" | ||
unbreaking: "耐久" | ||
vanishing_curse: "消失诅咒" | ||
wind_burst: "风爆" |