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);
        }
Esempio n. 2
0
        public MKTModMeta(string modPath)
        {
            JObject json = MKTCore.LoadJSON(Path.Combine(modPath, "_Meta.json"));

            this.name       = json.Value <string>("Mod");
            this.translator = json.Value <string>("Translator");
            this.inspector  = json.Value <string>("Inspector");
            this.modVersion = new Version(json.Value <string>("Version"));
            this.MKTVersion = new Version(json.Value <string>("MKT") != null? json.Value <string>("MKT"): "0.3.0");
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public void Load()
        {
            // 번역파일 로드
            JObject json = MKTCore.LoadJSON(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt"), true);

            if (json["items"] != null)
            {
                foreach (KeyValuePair <string, JToken> pair in json.Value <JObject>("items"))
                {
                    ModTranslation translation = mod.CreateTranslation(pair.Key);
                    translation.AddTranslation(Language.ActiveCulture, pair.Value.ToObject <string>());
                    mod.AddTranslation(translation);
                }
            }
        }
        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());
            }
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public MKTMod(Mod mod)
 {
     this.mod     = mod;
     this.version = mod.Version;
     this.path    = Path.Combine(MKTCore.translatorPath, "tr_" + mod.Name);
     this.langs   = new Dictionary <string, MKTModLang>();
     // 0.3.0 번역호환
     if (Directory.Exists(Path.Combine(MKTCore.translatorPath, mod.Name)))
     {
         try
         {
             Directory.Move(Path.Combine(MKTCore.translatorPath, mod.Name), path);
         }
         catch
         {
             // 실패시 수동변경
         }
     }
     if (File.Exists(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt")) && !ModContent.GetInstance <Config>().TranslatorMode)
     {
         this.active = true;
         this.meta   = new MKTModMeta(MKTCore.LoadJSON(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt"), true).Value <JObject>("meta"));
         Load();
     }
     else if (File.Exists(Path.Combine(path, "_Meta.json")))
     {
         this.active = true;
         this.meta   = new MKTModMeta(path);
         // 번역파일 로드
         Compile();
         Load();
     }
     else
     {
         this.meta = new MKTModMeta(mod);
     }
 }
 public MKTModLang(string path)
 {
     this._json = MKTCore.LoadJSON(path);
 }
Esempio n. 9
0
        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);
            }
        }