public string MakePotFile(string input) { string csharpFilePath = System.IO.Path.Combine(Path, "csharp.cs"); File.WriteAllText(csharpFilePath, input); var pot = new MakePot.MakePot(); pot.OutputFile = System.IO.Path.Combine(Path, "output.pot"); pot.CSharpFiles = EnvironmentForTest.CreateTaskItemsForFilePath(csharpFilePath); pot.Execute(); return(File.ReadAllText(pot.OutputFile)); }
public void MatchesInCSharpString_StringWithTilde_HasMatch() { string contents = @" somevar.MyLocalizableFunction('~MyLocalizableString'); ".Replace("'", "\""); var pot = new MakePot.MakePot(); MatchCollection matches = pot.MatchesInCSharpString(contents); Assert.AreEqual(1, matches.Count); foreach (Match match in matches) { Assert.AreEqual(3, match.Groups.Count); Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value); } }
public void MatchesInCSharpString_UsingTextEqual_HasMatchAndNotes() { string contents = @" somevar.Text = 'MyLocalizableString'; ".Replace("'", "\""); var pot = new MakePot.MakePot(); MatchCollection matches = pot.MatchesInCSharpString(contents); Assert.AreEqual(1, matches.Count); foreach (Match match in matches) { Assert.AreEqual(3, match.Groups.Count); Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value); } }
public void MatchesInCSharpString_UsingStringCatalogNoTilde_HasMatchAndNotes() { string contents = @" somevar.MyLocalizableFunction(StringCatalog.Get('MyLocalizableString', 'MyTranslationNotes')); ".Replace("'", "\""); var pot = new MakePot.MakePot(); MatchCollection matches = pot.MatchesInCSharpString(contents); Assert.AreEqual(1, matches.Count); foreach (Match match in matches) { Assert.AreEqual(3, match.Groups.Count); Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value); Assert.AreEqual("MyTranslationNotes", match.Groups["note"].Value); } }
public void MatchesInCSharpString_StringWithTildeAndNotes_HasMatchAndNotes() { var contents = @" somevar.MyLocalizableFunction('~MyLocalizableString', 'MyTranslationNotes'); ".Replace("'", "\""); var pot = new MakePot.MakePot(); var matches = pot.MatchesInCSharpString(contents); Assert.AreEqual(1, matches.Count); foreach (Match match in matches) { Assert.AreEqual(3, match.Groups.Count); Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value); Assert.AreEqual("MyTranslationNotes", match.Groups["note"].Value); } }
public string MakePotFile(string input) { var csharpFilePath = Path.Combine(TempDir, "csharp.cs"); File.WriteAllText(csharpFilePath, input); var pot = new MakePot.MakePot { OutputFile = Path.Combine(TempDir, "output.pot"), CSharpFiles = CreateTaskItemsForFilePath(csharpFilePath), ProjectId = "Testing", MsdIdBugsTo = "*****@*****.**" }; pot.Execute(); return(File.ReadAllText(pot.OutputFile)); }
public void MatchesInCSharpString_StringWithBackslashQuote_MatchesToEndOfString() { string contents = @" somevar.Text = 'MyLocalizableString \'InQuote\' end'; ".Replace("'", "\""); string expected = "MyLocalizableString \\\"InQuote\\\" end"; var pot = new MakePot.MakePot(); MatchCollection matches = pot.MatchesInCSharpString(contents); Assert.AreEqual(1, matches.Count); foreach (Match match in matches) { Assert.AreEqual(3, match.Groups.Count); Assert.AreEqual(expected, match.Groups["key"].Value); } }