public static void TestAddItemTranslation() { try { var type = ModLoader.GetMod("Bluemagic").ItemType("PuriumBreastplate"); if (type > 0) { TranslateTool.AddItemNameTranslation(ItemLoader.GetItem(type), "测试item名字", GameCulture.Chinese); TranslateTool.AddItemTooltipTranslation(ItemLoader.GetItem(type), "测试tooltip", GameCulture.Chinese); TranslateTool.AddSetBonusTranslation(ItemLoader.GetItem(type), "测试setbonus", GameCulture.Chinese); } } catch (Exception ex) { ErrorLogger.Log(ex.ToString()); } }
public static void ImportItemTexts(Mod mod, string path) { using (var fs = new FileStream(Path.Combine(path, "Items.json"), FileMode.Open)) { using (var sr = new StreamReader(fs)) { var items = JsonConvert.DeserializeObject <TextFile.ItemFile>(sr.ReadToEnd()); foreach (var item in items.Items) { var moditem = mod.GetItem(item.Key); if (moditem == null) { continue; } if (!string.IsNullOrWhiteSpace(item.Value.NameTranslation)) { TranslateTool.AddItemNameTranslation(moditem, item.Value.NameTranslation, GameCulture.Chinese); } if (!string.IsNullOrWhiteSpace(item.Value.TooltipTranslation)) { TranslateTool.AddItemTooltipTranslation(moditem, item.Value.TooltipTranslation, GameCulture.Chinese); } } foreach (var setbonus in items.SetBonus) { if (!string.IsNullOrWhiteSpace(setbonus.Value.Translation)) { TranslateTool.AddSetBonusTranslation(mod.GetItem(setbonus.Key), setbonus.Value.Translation, GameCulture.Chinese); } } } } }