From 7768d14b36d5f6d690513005774095b7fd0f8112 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 28 Sep 2017 17:31:55 -0400 Subject: [PATCH 1/5] Recommitting just these changes on a separate branch: - Making it run on js files - Making it not autoinsert angular brackets --- .../Ids.Parsers.XliffGenerator/HtmlCompiler.fs | 2 +- LocalizationCompiler/LocalizationCompiler/Program.fs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs b/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs index dc52638..55a104b 100644 --- a/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs +++ b/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs @@ -77,7 +77,7 @@ module Generators = let private deTag (t : LocalizationSourcePart) : string = match t with | Text s -> s - | Variable s -> "{{" + s + "}}" + | Variable s -> s let private deTagAttr (t : LocalizationSourcePart) : string = match t with diff --git a/LocalizationCompiler/LocalizationCompiler/Program.fs b/LocalizationCompiler/LocalizationCompiler/Program.fs index 447d624..ee6339f 100644 --- a/LocalizationCompiler/LocalizationCompiler/Program.fs +++ b/LocalizationCompiler/LocalizationCompiler/Program.fs @@ -17,11 +17,12 @@ module Program = open Ids.Localization.Parsers open Ids.Localization.Parsers.XliffGenerator.XliffGenerator + let supportedFileTypes = new System.Text.RegularExpressions.Regex("htm|html|js") + let rec generateXlfFromFiles (d : DirectoryInfo) (x : XliffGenerator) = printfn "%s" d.FullName - let r = new System.Text.RegularExpressions.Regex("htm|html") d.EnumerateFiles() - |> Seq.filter(fun f -> r.IsMatch(f.Extension)) + |> Seq.filter(fun f -> supportedFileTypes.IsMatch(f.Extension)) |> Seq.iter(fun f -> printfn "\t%s" f.Name x.Generate f.Name (LocalizationTagParser.parse (File.ReadAllText(f.FullName))) |> ignore) @@ -39,12 +40,11 @@ module Program = let rec generateApplicationFromXlf (tags : LocalizationMatch seq) (applicationDirectory : DirectoryInfo) (outputDirectory : DirectoryInfo) = printfn "%s" applicationDirectory.FullName - let r = new System.Text.RegularExpressions.Regex("htm|html") applicationDirectory.EnumerateFiles() |> Seq.iter(fun f -> let outputName = Path.Combine(outputDirectory.FullName, f.Name) - if f.Extension |> r.IsMatch then + if f.Extension |> supportedFileTypes.IsMatch then printMatchedFile f let newContents = HtmlCompiler.generateNewHtmlFile (File.ReadAllText f.FullName) tags From f82670ace0734c9ad780e3adaefef02ca78395e3 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 3 Oct 2017 16:11:36 -0400 Subject: [PATCH 2/5] Fixed part of the project not building. --- LocalizationCompiler/LocalizationCompiler.sln | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LocalizationCompiler/LocalizationCompiler.sln b/LocalizationCompiler/LocalizationCompiler.sln index 06a6af5..efe7c7f 100644 --- a/LocalizationCompiler/LocalizationCompiler.sln +++ b/LocalizationCompiler/LocalizationCompiler.sln @@ -49,11 +49,13 @@ Global {357E9998-74F6-48FD-8A08-6929114791BE}.Release|Mixed Platforms.Build.0 = Release|Any CPU {357E9998-74F6-48FD-8A08-6929114791BE}.Release|x86.ActiveCfg = Release|Any CPU {C74568BA-270A-4D22-8603-9A5321E50F1A}.Debug|Any CPU.ActiveCfg = Debug|x86 + {C74568BA-270A-4D22-8603-9A5321E50F1A}.Debug|Any CPU.Build.0 = Debug|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Debug|Mixed Platforms.Build.0 = Debug|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Debug|x86.ActiveCfg = Debug|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Debug|x86.Build.0 = Debug|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Release|Any CPU.ActiveCfg = Release|x86 + {C74568BA-270A-4D22-8603-9A5321E50F1A}.Release|Any CPU.Build.0 = Release|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Release|Mixed Platforms.ActiveCfg = Release|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Release|Mixed Platforms.Build.0 = Release|x86 {C74568BA-270A-4D22-8603-9A5321E50F1A}.Release|x86.ActiveCfg = Release|x86 From e96580f75f28eb565fadea5ebb94bcd69687e446 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 9 Oct 2017 12:13:52 -0400 Subject: [PATCH 3/5] Added namespace --- LocalizationCompiler/LocalizationCompiler/Program.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LocalizationCompiler/LocalizationCompiler/Program.fs b/LocalizationCompiler/LocalizationCompiler/Program.fs index ee6339f..97e9bb5 100644 --- a/LocalizationCompiler/LocalizationCompiler/Program.fs +++ b/LocalizationCompiler/LocalizationCompiler/Program.fs @@ -16,8 +16,9 @@ module Program = open Ids.Generators open Ids.Localization.Parsers open Ids.Localization.Parsers.XliffGenerator.XliffGenerator + open System.Text.RegularExpressions - let supportedFileTypes = new System.Text.RegularExpressions.Regex("htm|html|js") + let supportedFileTypes = new Regex("htm|html|js") let rec generateXlfFromFiles (d : DirectoryInfo) (x : XliffGenerator) = printfn "%s" d.FullName From e1cc9ff2d5b038d70cbb045d865f73dc7b49c18f Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 11 Oct 2017 12:36:51 -0400 Subject: [PATCH 4/5] Hopefully fixed bug with compiler inserting extraneous newline if string starts with a variable --- .../Ids.Parsers.XliffGenerator/HtmlCompiler.fs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs b/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs index 55a104b..43c5abd 100644 --- a/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs +++ b/LocalizationCompiler/Ids.Parsers.XliffGenerator/HtmlCompiler.fs @@ -109,5 +109,11 @@ module Generators = let rest = Text.NormalizeNewlines(contents).Substring(int32(endPosition.Index)) match x with | [] -> rest - | x -> (x |> Seq.map(fun (leader, tag) -> (leader, generateIdTag(tag))) |> Seq.map (fun (leader, tag) -> leader + (getTranslation matches tag)) |> Seq.reduce (+)) + rest + | x -> (x + |> Seq.map(fun (leader, tag) -> (leader, generateIdTag(tag))) + // DS: The Trim() is there because the xml generator puts a variable on a new line + // if the string starts with a variable, which messes up js formatting because + // js strings can only be on one line. + |> Seq.map (fun (leader, tag) -> leader + (getTranslation matches tag).Trim()) + |> Seq.reduce (+)) + rest | Failure (reasons, state, _) -> reasons From 8e4fa34b746946229ad35f2cbcb800f3fdf533cf Mon Sep 17 00:00:00 2001 From: Clay Woodard Date: Tue, 24 Oct 2017 14:54:14 -0400 Subject: [PATCH 5/5] changing target locale to en from en-US --- .../Ids.Parsers.XliffGenerator/XliffGenerator.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LocalizationCompiler/Ids.Parsers.XliffGenerator/XliffGenerator.fs b/LocalizationCompiler/Ids.Parsers.XliffGenerator/XliffGenerator.fs index e200914..a045475 100644 --- a/LocalizationCompiler/Ids.Parsers.XliffGenerator/XliffGenerator.fs +++ b/LocalizationCompiler/Ids.Parsers.XliffGenerator/XliffGenerator.fs @@ -93,7 +93,7 @@ module XliffGenerator = member x.Generate originalFileName (localizationTags : LocalizationTag seq) = fileNodeOriginalAttribute.Value <- originalFileName - targetLanguageAttribute.Value <- "en-US" + targetLanguageAttribute.Value <- "en" localizationTags |> Seq.map generateIdTag |> Seq.iter tagToXmlElement