Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Skovhede <kenneth@hexad.dk>2016-09-27 21:40:18 +0300
committerKenneth Skovhede <kenneth@hexad.dk>2016-09-27 21:40:18 +0300
commit74b65e284b2efc2d9f4fbc93bc050f9b6a7803c5 (patch)
tree2d1ab75315387ee60e4e4f6c56af357c2f8fd085 /BuildTools
parent3df5a8e21d8b1a0a6f45f044c3b139e864b15420 (diff)
Various fixes for generating the localization files
Diffstat (limited to 'BuildTools')
-rw-r--r--BuildTools/LocalizationTool2/Program.cs30
1 files changed, 18 insertions, 12 deletions
diff --git a/BuildTools/LocalizationTool2/Program.cs b/BuildTools/LocalizationTool2/Program.cs
index c443dc242..ba911af69 100644
--- a/BuildTools/LocalizationTool2/Program.cs
+++ b/BuildTools/LocalizationTool2/Program.cs
@@ -16,6 +16,10 @@ namespace LocalizationTool2
sourcefolder = Path.GetFullPath(sourcefolder.Replace("~", Environment.GetEnvironmentVariable("HOME")));
+ var targetfolder = sourcefolder;
+ if (args == null || args.Length > 1)
+ targetfolder = Path.GetFullPath(args[1].Replace("~", Environment.GetEnvironmentVariable("HOME")));
+
if (!Directory.Exists(sourcefolder))
{
@@ -30,7 +34,7 @@ namespace LocalizationTool2
var searchlist = new Dictionary<string, Regex>();
searchlist.Add("html", new Regex("((\\{\\{)|(ng-bind-html\\s*=\\s*\"))\\s*\\'(?<sourcestring>(\\\\\\'|[^\\'])+)\\'\\s*\\|\\s*localize(\\s|\\:|\\})", RegexOptions.Multiline | RegexOptions.IgnoreCase));
searchlist.Add("js", new Regex("Localization\\.localize\\(\\s*((\\'(?<sourcestring>(\\\\\\'|[^\\'])+)\\')|(\\\"(?<sourcestring>(\\\\\\\"|[^\\\"])+)\\\"))", RegexOptions.Multiline | RegexOptions.IgnoreCase));
- searchlist.Add("cs", new Regex("LC.L\\s*\\(((@\\s*\"(?<sourcestring>(\"\"|[^\"])+))|(\"(?<sourcestring>(\\\\\"|[^\"])+)))\"\\s*\\)", RegexOptions.Multiline | RegexOptions.IgnoreCase));
+ searchlist.Add("cs", new Regex("LC.L\\s*\\(((@\\s*\"(?<sourcestring>(\"\"|[^\"])+))|(\"(?<sourcestring>(\\\\\"|[^\"])+)))\"\\s*(\\)|,)", RegexOptions.Multiline | RegexOptions.IgnoreCase));
var map = new Dictionary<string, LocalizationEntry>();
@@ -46,7 +50,7 @@ namespace LocalizationTool2
foreach (Match match in re.Matches(txt))
{
var linepos = txt.Substring(match.Index).Count(x => x == '\n');
- var str = match.Groups["sourcestring"].Value;
+ var str = match.Groups["sourcestring"].Value.Replace("\n", "\\n").Replace("\r", "\\r");
LocalizationEntry le;
if (!map.TryGetValue(str, out le))
map[str] = new LocalizationEntry(str, f.Substring(sourcefolder.Length), linepos);
@@ -56,30 +60,32 @@ namespace LocalizationTool2
}
}
- File.WriteAllText(Path.Combine(sourcefolder, "translations.json"), Newtonsoft.Json.JsonConvert.SerializeObject(map.Values.OrderBy(x => x.SourceLocations.FirstOrDefault()).ToArray(), Newtonsoft.Json.Formatting.Indented));
- File.WriteAllText(Path.Combine(sourcefolder, "translations-list.json"), Newtonsoft.Json.JsonConvert.SerializeObject(map.Select(x => x.Key).OrderBy(x => x).ToArray(), Newtonsoft.Json.Formatting.Indented));
+ //File.WriteAllText(Path.Combine(sourcefolder, "translations.json"), Newtonsoft.Json.JsonConvert.SerializeObject(map.Values.OrderBy(x => x.SourceLocations.FirstOrDefault()).ToArray(), Newtonsoft.Json.Formatting.Indented));
+ //File.WriteAllText(Path.Combine(sourcefolder, "translations-list.json"), Newtonsoft.Json.JsonConvert.SerializeObject(map.Select(x => x.Key).OrderBy(x => x).ToArray(), Newtonsoft.Json.Formatting.Indented));
File.WriteAllLines(
- Path.Combine(sourcefolder, "translations.po"),
+ Path.Combine(targetfolder, "localization.po"),
map.OrderBy(x => x.Key).Select(x => x.Value).SelectMany(x => new string[] {
"#: " + x.SourceLocations.FirstOrDefault(),
- string.Format("msgid: \"{0}\"", (x.SourceString ?? "")),
- string.Format("msgstr: \"{0}\"", (x.SourceString ?? "")),
+ string.Format("msgid \"{0}\"", (x.SourceString ?? "")),
+ string.Format("msgstr \"{0}\"", (x.SourceString ?? "")),
""
}),
System.Text.Encoding.UTF8
);
- File.WriteAllLines(
- Path.Combine(sourcefolder, "translations-by-file.po"),
+ Console.WriteLine("Wrote {0} strings to {1}", map.Count, Path.Combine(targetfolder, "localization.po"));
+
+ /*File.WriteAllLines(
+ Path.Combine(sourcefolder, "localization-by-file.po"),
map.OrderBy(x => x.Value.SourceLocations.FirstOrDefault()).Select(x => x.Value).SelectMany(x => new string[] {
"#: " + x.SourceLocations.FirstOrDefault(),
- string.Format("msgid: \"{0}\"", (x.SourceString ?? "")),
- string.Format("msgstr: \"{0}\"", (x.SourceString ?? "")),
+ string.Format("msgid \"{0}\"", (x.SourceString ?? "")),
+ string.Format("msgstr \"{0}\"", (x.SourceString ?? "")),
""
}),
System.Text.Encoding.UTF8
- );
+ );*/
return 0;