public void ExportProject(string paramFilename) { string path = paramFilename + FOCUS_TREE_PATH; Directory.CreateDirectory(path); //For each parsed focus trees foreach (KeyValuePair <string, string> item in FocusTreeParser.ParseAllTrees(fociContainerList)) { using (TextWriter tw = new StreamWriter(path + item.Key + ".txt")) { tw.Write(item.Value); } } path = paramFilename + LOCALISATION_PATH; Directory.CreateDirectory(Path.GetDirectoryName(path)); LocalisationContainer loct = null; //For each parsed localisation files foreach (KeyValuePair <string, string> item in LocalisationParser.ParseEverything(localisationList)) { //localisationList.IndexOf(loct, 0); //fork //fixed localization files save in UTF-8 with BOM format loct = localisationList[0]; using (Stream stream = File.OpenWrite(path + item.Key + "_" + loct.LanguageName + ".yml")) //save in file name eg.'test_l_english.yml' using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding(true))) { tw.Write(item.Value); } } path = paramFilename + EVENTS_PATH; Directory.CreateDirectory(Path.GetDirectoryName(path)); //For each parsed event file foreach (KeyValuePair <string, string> item in EventParser.ParseAllEvents(eventList)) { //using (TextWriter tw = new StreamWriter(path + item.Key + ".txt")) //fork need to be UTF-8 with BOM using (TextWriter tw = new StreamWriter(path + item.Key + ".txt", false, new UTF8Encoding(true))) { tw.Write(item.Value); } } //For each parsed script file foreach (KeyValuePair <string, string> item in ScriptParser.ParseEverything(scriptList)) { using (TextWriter tw = new StreamWriter(paramFilename + "\\" + item.Key + ".txt")) { tw.Write(item.Value); } } }
public void ExportProject(string paramFilename) { string path = paramFilename + FOCUS_TREE_PATH; Directory.CreateDirectory(path); //For each parsed focus trees foreach (KeyValuePair <string, string> item in FocusTreeParser.ParseAllTrees(fociContainerList)) { using (TextWriter tw = new StreamWriter(path + item.Key + ".txt")) { tw.Write(item.Value); } } path = paramFilename + LOCALISATION_PATH; Directory.CreateDirectory(Path.GetDirectoryName(path)); //For each parsed localisation files foreach (KeyValuePair <string, string> item in LocalisationParser.ParseEverything(localisationList)) { using (Stream stream = File.OpenWrite(path + item.Key + ".yml")) using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding())) { tw.Write(item.Value); } } path = paramFilename + EVENTS_PATH; Directory.CreateDirectory(Path.GetDirectoryName(path)); //For each parsed event file foreach (KeyValuePair <string, string> item in EventParser.ParseAllEvents(eventList)) { using (TextWriter tw = new StreamWriter(path + item.Key + ".txt")) { tw.Write(item.Value); } } //For each parsed script file foreach (KeyValuePair <string, string> item in ScriptParser.ParseEverything(scriptList)) { using (TextWriter tw = new StreamWriter(paramFilename + "\\" + item.Key + ".txt")) { tw.Write(item.Value); } } }
private void TestLocaleToScript(LocalisationModel model) { //Arrange LocalisationContainer container = new LocalisationContainer(model); List <LocalisationContainer> list = new List <LocalisationContainer> { container }; //Act Dictionary <string, string> files = LocalisationParser.ParseEverything(list); string filecontent = files.FirstOrDefault().Value; string fileName = files.FirstOrDefault().Key; //Assert Assert.IsNotNull(filecontent); Assert.IsNotNull(fileName); Assert.AreEqual(fileName, "focus_l_english"); }
public void ExportProject() { var dialog = new CommonOpenFileDialog(); ResourceDictionary resourceLocalization = new ResourceDictionary(); resourceLocalization.Source = new Uri(Configurator.getLanguageFile(), UriKind.Relative); dialog.Title = resourceLocalization["Project_Export"] as string; dialog.IsFolderPicker = true; dialog.InitialDirectory = "C:"; dialog.AddToMostRecentlyUsedList = false; dialog.AllowNonFileSystemItems = false; dialog.DefaultDirectory = "C:"; dialog.EnsureFileExists = true; dialog.EnsurePathExists = true; dialog.EnsureReadOnly = false; dialog.EnsureValidNames = true; dialog.Multiselect = false; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { //For each parsed focus trees foreach (KeyValuePair <string, string> item in FocusTreeParser.ParseAllTrees(project.fociContainerList)) { using (TextWriter tw = new StreamWriter(dialog.FileName + "\\" + item.Key + ".txt")) { tw.Write(item.Value); } } //For each parsed localisation files foreach (KeyValuePair <string, string> item in LocalisationParser.ParseEverything(project.localisationList)) { using (TextWriter tw = new StreamWriter(dialog.FileName + "\\" + item.Key + ".yaml")) { tw.Write(item.Value); } } //TODO: For each parsed event } }