private void DumpUserLocalization() { MKTModLang lang = new MKTModLang(); JObject modLocal = JObject.Parse(Encoding.UTF8.GetString(tModKoreanTranslator.instance.GetFileBytes("Localization/ztnc.Terraria.Localization.json"))); Directory.CreateDirectory(translatorPath); LocalizedText[] rawdata = LanguageManager.Instance.FindAll(new Regex(".+")); foreach (LocalizedText t in rawdata) { string[] keys = t.Key.Split('.'); string key1 = keys[0]; string key2 = keys[1]; if (modLocal[key1] != null) { if (modLocal[key1][key2] != null) { lang.Add2(key1, key2, t.Value, modLocal[key1].Value <string>(key2)); } else { lang.Add(key1, key2, t.Value); } } else { lang.Add(key1, key2, t.Value); } } MKTCore.DumpJSON(Path.Combine(translatorPath, "Translations.json"), lang.json); }
public void Dump(string modPath) { JObject json = new JObject(); json.Add("Mod", name); json.Add("Translator", translator); json.Add("Inspector", inspector); json.Add("Version", modVersion.ToString()); json.Add("MKT", MKTVersion.ToString()); MKTCore.DumpJSON(Path.Combine(modPath, "_Meta.json"), json); }
private void LoadUserLocalization() { LanguageManager manager = LanguageManager.Instance; bool trMode = ModContent.GetInstance <Config>().TranslatorMode; if (File.Exists(Path.Combine(MKTCore.translatorPath, "Terraria.mkt")) && trMode == false) { manager.LoadLanguageFromFileText(MKTCore.LoadJSON(Path.Combine(MKTCore.translatorPath, "Terraria.mkt"), true).ToString()); } else if (File.Exists(Path.Combine(translatorPath, "Translations.json"))) { JObject json = MKTCore.Tr2LangCol3(MKTCore.LoadJSON(Path.Combine(translatorPath, "Translations.json")), false); MKTCore.DumpJSON(Path.Combine(MKTCore.translatorPath, "Terraria.mkt"), json, true); manager.LoadLanguageFromFileText(json.ToString()); } }
public void Compile() { // 번역파일 묶기 JObject json = new JObject(); string[] itemFiles = new string[] { "Items.json", "Prefixes.json", "NPCs.json", "Buffs.json" }; json.Add("meta", MKTCore.LoadJSON(Path.Combine(path, "_Meta.json"))); if (File.Exists(Path.Combine(path, "Translations.json"))) { json.Add("items", CompJSON(MKTCore.LoadJSON(Path.Combine(path, "Translations.json")), true)); } foreach (string file in itemFiles) { if (File.Exists(Path.Combine(path, file))) { json.Value <JObject>("items").Merge(CompJSON(MKTCore.LoadJSON(Path.Combine(path, file)))); } } MKTCore.DumpJSON(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt"), json, true); }
public void dump() { // 원시 번역파일 생성 Directory.CreateDirectory(path); meta.Dump(path); // 메타파일 생성 JObject temp = new JObject(); JObject npc = new JObject(); JObject item = new JObject(); JObject buff = new JObject(); JObject prefix = new JObject(); var regex = new System.Text.RegularExpressions.Regex($"Mods[.]{mod.Name}[.].*"); LocalizedText[] locals = LanguageManager.Instance.FindAll(regex); foreach (LocalizedText loc in locals) { if (loc.Key.Contains("#")) { continue; } string[] keys = loc.Key.Split('.'); // 0: Mods, 1: modName, 2: Kind, 3: internalName switch (keys[2]) { case "ItemName": case "ItemTooltip": case "MapObject": case "ProjectileName": AddLocaleItem(keys[2], keys[3], loc.Value, ref item); break; case "BuffName": case "BuffDescription": AddLocaleItem(keys[2], keys[3], loc.Value, ref buff); break; case "NPCName": AddLocaleItem(keys[2], keys[3], loc.Value, ref npc); break; case "Prefix": AddLocaleItem(keys[2], keys[3], loc.Value, ref prefix); break; default: AddLocaleItem(loc.Key, loc.Value, ref temp); break; } } if (temp.Count > 0) { MKTCore.DumpJSON(Path.Combine(path, "Translations.json"), temp); } if (item.Count > 0) { MKTCore.DumpJSON(Path.Combine(path, "Items.json"), item); } if (prefix.Count > 0) { MKTCore.DumpJSON(Path.Combine(path, "Prefixes.json"), prefix); } if (npc.Count > 0) { MKTCore.DumpJSON(Path.Combine(path, "NPCs.json"), npc); } if (buff.Count > 0) { MKTCore.DumpJSON(Path.Combine(path, "Buffs.json"), buff); } }