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:
authoragrajaghh <agrajaghh@gmail.com>2016-09-30 11:03:15 +0300
committeragrajaghh <agrajaghh@gmail.com>2016-09-30 11:03:15 +0300
commit93bbdf6db2fca47c412ab3dee4382db355adc4c7 (patch)
treed7ea946d1051ca1b387e8f606538782cc9e7c38f /BuildTools
parent5bdf012ede65d1f78ca50795cb167b2e282d5935 (diff)
fix tab indent
Diffstat (limited to 'BuildTools')
-rw-r--r--BuildTools/LocalizationTool2/Program.cs98
1 files changed, 49 insertions, 49 deletions
diff --git a/BuildTools/LocalizationTool2/Program.cs b/BuildTools/LocalizationTool2/Program.cs
index ba911af69..7030b7317 100644
--- a/BuildTools/LocalizationTool2/Program.cs
+++ b/BuildTools/LocalizationTool2/Program.cs
@@ -6,73 +6,73 @@ using System.Text.RegularExpressions;
namespace LocalizationTool2
{
- class MainClass
- {
- public static int Main(string[] args)
- {
- var sourcefolder = Environment.CurrentDirectory;
- if (args == null || args.Length != 0)
- sourcefolder = args[0];
+ class MainClass
+ {
+ public static int Main(string[] args)
+ {
+ var sourcefolder = Environment.CurrentDirectory;
+ if (args == null || args.Length != 0)
+ sourcefolder = args[0];
- sourcefolder = Path.GetFullPath(sourcefolder.Replace("~", Environment.GetEnvironmentVariable("HOME")));
+ 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))
- {
- Console.WriteLine("No such directory: {0}", sourcefolder);
- return 1;
- }
+ if (!Directory.Exists(sourcefolder))
+ {
+ Console.WriteLine("No such directory: {0}", sourcefolder);
+ return 1;
+ }
- sourcefolder = Path.GetFullPath(sourcefolder);
- Console.WriteLine("Using directory {0}, scanning ....", sourcefolder);
+ sourcefolder = Path.GetFullPath(sourcefolder);
+ Console.WriteLine("Using directory {0}, scanning ....", sourcefolder);
- 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));
+ 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));
- var map = new Dictionary<string, LocalizationEntry>();
+ var map = new Dictionary<string, LocalizationEntry>();
if (!sourcefolder.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
sourcefolder += Path.DirectorySeparatorChar;
- foreach (var ext in searchlist.Keys)
- {
- var re = searchlist[ext];
- foreach (var f in Directory.GetFiles(sourcefolder, "*." + ext, SearchOption.AllDirectories))
- {
- var txt = File.ReadAllText(f);
- foreach (Match match in re.Matches(txt))
- {
- var linepos = txt.Substring(match.Index).Count(x => x == '\n');
+ foreach (var ext in searchlist.Keys)
+ {
+ var re = searchlist[ext];
+ foreach (var f in Directory.GetFiles(sourcefolder, "*." + ext, SearchOption.AllDirectories))
+ {
+ var txt = File.ReadAllText(f);
+ foreach (Match match in re.Matches(txt))
+ {
+ var linepos = txt.Substring(match.Index).Count(x => x == '\n');
var str = match.Groups["sourcestring"].Value.Replace("\n", "\\n").Replace("\r", "\\r");
- LocalizationEntry le;
- if (!map.TryGetValue(str, out le))
+ LocalizationEntry le;
+ if (!map.TryGetValue(str, out le))
map[str] = new LocalizationEntry(str, f.Substring(sourcefolder.Length), linepos);
- else
- le.AddSource(Path.GetFileName(f), linepos);
- }
- }
- }
-
- //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(targetfolder, "localization.po"),
- map.OrderBy(x => x.Key).Select(x => x.Value).SelectMany(x => new string[] {
- "#: " + x.SourceLocations.FirstOrDefault(),
+ else
+ le.AddSource(Path.GetFileName(f), linepos);
+ }
+ }
+ }
+
+ //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(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 ?? "")),
""
- }),
- System.Text.Encoding.UTF8
- );
+ }),
+ System.Text.Encoding.UTF8
+ );
Console.WriteLine("Wrote {0} strings to {1}", map.Count, Path.Combine(targetfolder, "localization.po"));
@@ -87,8 +87,8 @@ namespace LocalizationTool2
System.Text.Encoding.UTF8
);*/
- return 0;
+ return 0;
- }
- }
+ }
+ }
}