public static void InsertLocale(string from, string groupName, string name, string language, string value) { if (!LocaleSystem.ExistsGroup(from, groupName)) { LocaleSystem.CreateGroup(from, groupName); } LocaleElement newLe = new LocaleElement(name, language, value); bool done = false; FileInfo fi = new FileInfo(LocaleSystem.GetDirectoryString(from) + groupName + ".tsv"); List <LocaleElement> list = LocaleSystem.GetAll(from, groupName); using (StreamWriter sw = new StreamWriter(fi.Open(FileMode.Truncate, FileAccess.Write, FileShare.Write))) { foreach (LocaleElement le in list) { if (le.Name == name && le.Language == language) { done = true; } le.WriteToFile(sw); } if (!done) { newLe.WriteToFile(sw); } } }
public static void RemoveLocale(string from, string groupName, string name) { if (LocaleSystem.ExistsGroup(from, groupName)) { FileInfo fi = new FileInfo(LocaleSystem.GetDirectoryString(from) + groupName + ".tsv"); List <LocaleElement> list = LocaleSystem.GetAll(from, groupName); using (StreamWriter sw = new StreamWriter(fi.Open(FileMode.Truncate, FileAccess.Write, FileShare.Write))) { foreach (LocaleElement le in list) { if (!(le.Name == name)) { le.WriteToFile(sw); } } } } }