diff --git a/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj b/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj index 759b992..a0a58ce 100644 --- a/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj +++ b/MN.L10n.BuildTasks/MN.L10n.BuildTasks.csproj @@ -6,7 +6,7 @@ Exe MN.L10n.BuildTasks.Program true - 4.0.4 + 4.0.5 Chris Gårdenberg MultiNet Interactive AB diff --git a/MN.L10n.Tests/ParserTests.cs b/MN.L10n.Tests/ParserTests.cs index 297d2a4..4ae8f41 100644 --- a/MN.L10n.Tests/ParserTests.cs +++ b/MN.L10n.Tests/ParserTests.cs @@ -166,5 +166,15 @@ public void TestEscapedStringContainerCharacterVerbatim() Assert.Single(result); Assert.Equal(@"Hej ""bror""\nNej", result[0].Phrase.Trim()); } + + [Fact] + public void TestNewlineInJsTemplateString() + { + var src = "_s(`Hello\r\nbrother!`)"; + var parser = new L10nParser(); + var result = parser.Parse(src).ToList(); + Assert.Single(result); + Assert.Equal("Hello\nbrother!", result[0].Phrase.Trim()); + } } } diff --git a/MN.L10n/L10nParser.cs b/MN.L10n/L10nParser.cs index 889cc2b..d035869 100644 --- a/MN.L10n/L10nParser.cs +++ b/MN.L10n/L10nParser.cs @@ -209,6 +209,12 @@ private PhraseInvocation Unescape(PhraseInvocation phraseInvocation, bool isVerb } else { + if (phraseInvocation.StringContainer == '`') + { + phraseInvocation.Phrase = phraseInvocation.Phrase + .Replace("\r", ""); + } + for (var i = 0; i < phraseInvocation.Phrase.Length; i++) { if (phraseInvocation.Phrase[i] == '\\' && i + 1 < phraseInvocation.Phrase.Length) diff --git a/MN.L10n/MN.L10n.csproj b/MN.L10n/MN.L10n.csproj index f528924..fcafe24 100644 --- a/MN.L10n/MN.L10n.csproj +++ b/MN.L10n/MN.L10n.csproj @@ -12,14 +12,14 @@ Translation package https://github.com/MultinetInteractive/MN.L10n git © 20XX MultiNet Interactive AB - 4.1.3 + 4.1.4 latest True Now includes analyzer Library - 4.1.3 + 4.1.4