void SaveData(string type, string lang, Dictionary <string, string> lst) { string resLang1 = Path.Combine(_paths.LocalizationRoot, lang + ".json"); var data = new AbpResourceFile { Culture = lang, Texts = lst.OrderBy(e => e.Key).ToDictionary(e => e.Key, e => e.Value) }; File.WriteAllText(resLang1, data.ToJsonIndent()); }
Dictionary <string, string> GetItems(string type, string locale) { var ret = new Dictionary <string, string>(); string resPath = Path.Combine(_paths.LocalizationRoot, locale + ".json"); if (File.Exists(resPath)) { AbpResourceFile file = File.ReadAllText(resPath).FromJson <AbpResourceFile>(); ret = file.Texts; } return(ret); }
public override void Import(string type, string lang, List <DataItem> strs, bool suspendOut = false) { var data = strs.OrderBy(e => e.Name).ToDictionary(e => e.Name, e => e.Value); var obj = new AbpResourceFile { Culture = lang, Texts = new Dictionary <string, string>() }; string resLang1 = Path.Combine(_paths.LocalizationRoot, lang + ".json"); Utils.CreateFolderForFile(resLang1); if (File.Exists(resLang1)) { obj = File.ReadAllText(resLang1).FromJson <AbpResourceFile>(); } foreach (var item in strs) { if (!obj.Texts.ContainsKey(item.Name)) { obj.Texts[item.Name] = item.Value ?? LangUtils.IdToPhrase(item.Name); } } SaveData(type, lang, obj.Texts); }