public void CanExtractSimpleFile(string filename) { var bundle = EmbeddedFilesReader.ReadString("XliffLib.Integration.TestFiles." + filename + ".json").ToBundle(); var xliff = EmbeddedFilesReader.ReadString("XliffLib.Integration.TestFiles." + filename + ".xlf"); var extractor = new SimpleExtractor(); var xliffModel = extractor.Extract(bundle, "en-US", "it-IT"); var xliffString = extractor.Write(xliffModel, true); var cleanedExpected = System.Text.RegularExpressions.Regex.Replace(xliff, @"\s+", " "); var cleanedResult = System.Text.RegularExpressions.Regex.Replace(xliffString, @"\s+", " "); Assert.AreEqual(cleanedExpected, cleanedResult); }
static void Main(string[] args) { var path = System.Reflection.Assembly.GetExecutingAssembly().Location; var directory = System.IO.Path.GetDirectoryName(path); var content = System.IO.File.ReadAllText(Path.Combine(directory, "Samples", "original.txt")); var bundle = new Bundle(); var doc = new Document(); bundle.Documents.Add(doc); var property = new Property("original", content); doc.Containers.Add(property); Extractor extractor = new SimpleExtractor(); //Extractor extractor = new DefaultExtractor(); XliffDocument xliff = extractor.Extract(bundle, "en-GB", "it-IT"); try { var result = extractor.Write(xliff, true); Console.WriteLine(result); } catch (ValidationException e) { Console.WriteLine("ValidationException Details:"); Console.WriteLine(e.Message); if (e.Data != null) { foreach (var key in e.Data.Keys) { Console.WriteLine(" '{0}': '{1}'", key, e.Data[key]); } } } Console.ReadLine(); }
public void SetUp() { Extractor = new SimpleExtractor(); }