public void TestExtractLocalizableStrings() { var extractor = new Extractor(); const string destinationXml = "LocalizationCopy.xml"; try { File.Copy(@"LocalizableStringExtractor\Cases\Localization.xml", destinationXml, true); extractor.ExtractLocalizableStrings( new [] { @"LocalizableStringExtractor\Cases" }, destinationXml, EmptyArray<string>.Instance); // Read back in the output XML file and check that it has the right data. var stringItems = new List<LocalizableString>(extractor.ReadLocalizationFile(destinationXml)); LocalizableString item = stringItems.Find(a => a.Text == "Original" && a.Translation == "Translation"); Assert.IsTrue(item != null); item = stringItems.Find(a => a.Text == @"%$Name/\Symbols$%"); //from \Cases\Standard.xaml Assert.IsTrue(item != null); item = stringItems.Find(a => a.Text == @"About"); //from \Cases\AboutDialog.xaml Assert.IsTrue(item != null); item = stringItems.Find(a => a.Text == "Speaker" && a.Context == "an electronic speaker, for playing sounds"); Assert.IsTrue(item != null && item.Translation == "Speaker translated"); item = stringItems.Find(a => a.Text == "Speaker" && a.Context == "a person speaking at a podium"); Assert.IsTrue(item != null && item.Translation == "Speaker translated"); } finally { File.Delete(destinationXml); } }
private List<LocalizableString> ExtractFromXaml(string sourcePath) { string finalPath = Path.Combine("..\\..", sourcePath); var extractor = new Extractor(); List<LocalizableString> strings = extractor.ExtractFromXaml(finalPath).ToList(); return strings; }
// Extracts the list of localizable strings from the given *.cs file. // 'sourcePath' is assumed to be a filename in \Cases. private List<LocalizableString> ExtractFromCs(string sourcePath) { string finalPath = Path.Combine("LocalizableStringExtractor\\Cases", sourcePath); var extractor = new Extractor(); List<LocalizableString> strings = extractor.ExtractFromCs(finalPath).ToList(); return strings; }