static void Main(string[] args) { // var inputXmlFName = @"d:\code\translationSearcher\StockSharp xmls\a.xml";//StockSharp.Messages.xml"; // var outputCsvFName = Path.ChangeExtension(inputXmlFName,"csv"); // var textCsvFName = @"d:\code\translationSearcher\text.csv"; // var outputXmlFName = Path.Combine(Path.GetDirectoryName(inputXmlFName), // Path.GetFileNameWithoutExtension(inputXmlFName) + "_tr.xml"); try { var tr = new XmlTranslation(); if (args.Length == 2) { var inputXmlFName = args[0]; var textCsvFName = args[1]; var outputCsvFName = Path.ChangeExtension(inputXmlFName, "csv"); tr.SearchTranslationsForXml(inputXmlFName, textCsvFName, outputCsvFName); } else if (args.Length == 3) { var inputXmlFName = args[0]; var textCsvFName = args[1]; var outputCsvFName = Path.ChangeExtension(inputXmlFName, "csv"); var outputXmlFName = args[2]; tr.TranslateXml(inputXmlFName, outputCsvFName, textCsvFName, 1, outputXmlFName); } } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { // MichaelsTest(); // return; // var inputXmlFName = @"d:\code\translationSearcher\StockSharp xmls\a.xml";//StockSharp.Messages.xml"; // var outputCsvFName = Path.ChangeExtension(inputXmlFName,"csv"); // var textCsvFName = @"d:\code\translationSearcher\text.csv"; // var outputXmlFName = Path.Combine(Path.GetDirectoryName(inputXmlFName), // Path.GetFileNameWithoutExtension(inputXmlFName) + "_tr.xml"); try { var tr = new XmlTranslation(); if (args.Length == 2) { var inputXmlFName = args[0]; var textCsvFName = args[1]; var outputCsvFName = Path.ChangeExtension(inputXmlFName, "csv"); tr.SearchTranslationsForXml(inputXmlFName, textCsvFName, outputCsvFName); } else if (args.Length == 3) { var inputXmlFName = args[0]; var textCsvFName = args[1]; var outputCsvFName = Path.ChangeExtension(inputXmlFName, "csv"); var outputXmlFName = args[2]; tr.TranslateXml(inputXmlFName, outputCsvFName, textCsvFName, 1, outputXmlFName); } } catch (Exception e) { Console.WriteLine(e.Message); } }
static void MichaelsTest() { var tr = new XmlTranslation(); var refDir = @"d:\code\StockSharp\Localization\translationSearcher\translationSearcher\bin\Debug\StockSharp xmls"; var textCsvFName = @"d:\code\StockSharp\Localization\translationSearcher\translationSearcher\bin\Debug\text.csv"; foreach (var s in Directory.GetFiles(refDir, "StockSharp.*.xml")) { if (string.Compare(s, "StockSharp.Localization.xml", StringComparison.InvariantCultureIgnoreCase) == 0) { continue; } //var inputXmlFName = args[0]; //var textCsvFName = args[1]; var outputCsvFName = Path.ChangeExtension(s, "csv"); tr.SearchTranslationsForXml(s, textCsvFName, outputCsvFName); } foreach (var s in Directory.GetFiles(refDir, "StockSharp.*.xml")) { if (string.Compare(s, "StockSharp.Localization.xml", StringComparison.InvariantCultureIgnoreCase) == 0) { continue; } tr.TranslateXml(s, Path.ChangeExtension(s, "csv"), textCsvFName, 1, Path.Combine(refDir, "en")); } }
private void WriteDescriptor(XmlWriter writer, Hero hero, HeroLevel level, HeroDescriptor descriptor) { writer.WriteStartElement("SimulationDescriptor"); writer.WriteAttributeString("Name", descriptor.GetIdentifier(hero.Name, level.Level)); writer.WriteAttributeString("Type", XmlTranslation.AsText(descriptor.GetType(level.Level))); WriteModifiers(writer, descriptor); writer.WriteEndElement(); }
private EquipmentSlot CreateEquipmentSlot(XmlNode equipConfig) { return(new EquipmentSlot { Name = XmlTranslation.ValueAs <EquipmentName>(equipConfig.Attribute("Name")), Type = equipConfig.Attribute <WeaponType?>("Type"), }); }
private HeroLevel CreateHeroLevel(XmlNode heroConfig) { var level = new HeroLevel(); level.FoodCost = heroConfig.Attribute <int>("FoodCost"); level.Level = XmlTranslation.ValueAs <int>(heroConfig.Attribute("Name").Split("_LVL")[1]); level.Skills = heroConfig.Select("Skills/Skill", CreateSkill); return(level); }
private void WriteHeroLevels(XmlWriter writer, Hero hero) { hero.Levels.ForEach(level => { writer.WriteStartElement("HeroLevelConfig"); writer.WriteAttributeString("Name", level.GetFullIdentifier(hero.Name)); writer.WriteAttributeString("FoodCost", XmlTranslation.AsText(level.FoodCost)); WriteSkills(writer, level); writer.WriteEndElement(); }); }
private void WriteIntroDialogs(XmlWriter writer, Hero hero) { writer.WriteStartElement("IntroDialogs"); hero.IntroDialogs.ForEach(dialog => { writer.WriteStartElement("Dialog"); writer.WriteAttributeString("Name", XmlTranslation.AsText(dialog.Name)); writer.WriteAttributeString("Text", XmlTranslation.AsText(dialog.Text)); writer.WriteEndElement(); }); writer.WriteEndElement(); }
private void WriteModifier(XmlWriter writer, ModifierDescriptor modifier) { writer.WriteStartElement("SimulationModifierDescriptor"); writer.WriteAttributeString("TargetProperty", modifier.TargetProperty.ToString()); writer.WriteAttributeString("Operation", modifier.Operation.ToString()); writer.WriteAttributeString("Value", Formatter.FormatNumericValue(modifier.Value)); if (modifier.Path != null) { writer.WriteAttributeString("Path", XmlTranslation.AsText(modifier.Path)); } writer.WriteEndElement(); }
private static IList <ModifierDescriptor> CreateModifiers(XmlNode simulationNode) { var descriptors = simulationNode.SelectNodes("SimulationModifierDescriptors/SimulationModifierDescriptor"); return(descriptors.AsQuery() .Select(x => new ModifierDescriptor { TargetProperty = x.Attributes["TargetProperty"].Value.ParseToEnum <TargetProperty>(), Operation = x.Attributes["Operation"].Value.ParseToEnum <Operation>(), Value = (float)Convert.ToDouble(x.Attributes["Value"].Value), Path = XmlTranslation.ValueAs <Path?>(x.Attributes["Path"]?.Value), }) .ToList()); }
private void WriteHeroConfig(XmlWriter writer, Hero hero) { writer.WriteStartElement("HeroConfig"); writer.WriteAttributeString("Name", hero.Identifier); writer.WriteAttributeString("RecruitmentFoodCost", XmlTranslation.AsText(hero.RecruitmentFoodCost)); writer.WriteAttributeString("AITargetType", XmlTranslation.AsText(hero.AITargetType)); writer.WriteAttributeString("AttackType", XmlTranslation.AsText(hero.AttackType)); writer.WriteAttributeString("Archetype", XmlTranslation.AsText(hero.Archetype)); writer.WriteAttributeString("UnlockLevelCount", XmlTranslation.AsText(hero.UnlockLevelCount)); writer.WriteAttributeString("Faction", XmlTranslation.AsText(hero.Faction)); WriteIntroDialogs(writer, hero); WriteEquipmentSlots(writer, hero); writer.WriteEndElement(); }
private void WriteEquipmentSlots(XmlWriter writer, Hero hero) { writer.WriteStartElement("EquipmentSlots"); hero.EquipmentSlots.ForEach(slot => { writer.WriteStartElement("EquipmentSlot"); writer.WriteAttributeString("Name", XmlTranslation.AsText(slot.Name)); if (slot.Type != null) { writer.WriteAttributeString("Type", XmlTranslation.AsText(slot.Type)); } writer.WriteEndElement(); }); writer.WriteEndElement(); }
string LookupTranslation(List <XmlTranslation> translations, UIDataString key) { XmlTranslation firstMatchOnPhrase = null; foreach (var translation in translations) { if (translation.PhraseKey == key.SourceUIString) { if (translation.Reference == key.ScriptureReference) { return(translation.Translation); } if (firstMatchOnPhrase == null) { firstMatchOnPhrase = translation; } } } return(firstMatchOnPhrase?.Translation); }
public static T Attribute <T>(this XmlNode node, string name) { return(XmlTranslation.ValueAs <T>(node.Attributes[name]?.Value)); }