using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod { public partial class CalamityUtils { /// The language key. This will have "Mods.CalamityMod." appended behind it. /// /// A instance found using the provided key with "Mods.CalamityMod." appended behind it. /// NOTE: Modded translations are not loaded until after PostSetupContent.Caching the result is suggested. /// public static LocalizedText GetText(string key) { return Language.GetOrRegister("Mods.CalamityMod." + key); } /// The language key. This will have "Mods.CalamityMod." appended behind it. /// /// A instance found using the provided key with "Mods.CalamityMod." appended behind it. /// NOTE: Modded translations are not loaded until after PostSetupContent.Caching the result is suggested. /// public static string GetTextValue(string key) { return Language.GetTextValue("Mods.CalamityMod." + key); } /// The item's ID. /// /// A instance for an item's name. /// NOTE: Modded translations are not loaded until after PostSetupContent.Caching the result is suggested. /// public static LocalizedText GetItemName(int itemID) { if (itemID < ItemID.Count) { return Language.GetText("ItemName." + ItemID.Search.GetName(itemID)); } var modItem = ItemLoader.GetItem(itemID); return modItem.GetLocalization("DisplayName"); } /// /// A instance which will have the item's translated name. /// NOTE: Modded translations are not loaded until after PostSetupContent.Caching the result is suggested. /// public static LocalizedText GetItemName() where T : ModItem { return GetItemName(ModContent.ItemType()); } } }