public static int Main(string[] args) { try { var logger = new Logger(); if (args.Length == 1) { string packPath = args[0]; WriteLine($"Parsing {packPath}", ConsoleColor.Cyan); var basePack = LanguagePack.LoadFromFile(packPath, logger); } else if (args.Length == 2) { string basePackPath = args[0]; string translationPackPath = args[1]; var basePack = LanguagePack.LoadFromFile(basePackPath, new FakeLogger()); WriteLine($"Parsing {translationPackPath}", ConsoleColor.Cyan); var translationPack = LanguagePack.LoadFromFile(translationPackPath, logger); foreach (var kvp in basePack.Entries) { int id = kvp.Key; string baseString = kvp.Value.Text; if (!translationPack.Entries.ContainsKey(id)) { string message = String.Format(" warning: No string for STR_{0:0000}: {1}", id, baseString); WriteLine(message, ConsoleColor.Yellow); } } } else { PrintUsageInfo(); return(ExitCodes.UsageInfo); } if (logger.HasErrors) { Console.WriteLine(); return(ExitCodes.Errors); } else if (logger.HasWarnings) { Console.WriteLine(); return(ExitCodes.Warnings); } } catch (IOException ex) { WriteLine($"Unable to open file: {ex.Message}", ConsoleColor.Red); return(ExitCodes.Fatal); } return(ExitCodes.OK); }
public static int Main(string[] args) { try { var logger = new Logger(); if (args.Length == 1) { string packPath = args[0]; WriteLine($"Parsing {packPath}", ConsoleColor.Cyan); var basePack = LanguagePack.LoadFromFile(packPath, logger); } else if (args.Length == 2) { string basePackPath = args[0]; string translationPackPath = args[1]; var basePack = LanguagePack.LoadFromFile(basePackPath, new FakeLogger()); WriteLine($"Parsing {translationPackPath}", ConsoleColor.Cyan); var translationPack = LanguagePack.LoadFromFile(translationPackPath, logger); } else { PrintUsageInfo(); return(ExitCodes.UsageInfo); } if (logger.HasWarnings || logger.HasErrors) { Console.WriteLine(); return(ExitCodes.Errors); } } catch (IOException ex) { WriteLine($"Unable to open file: {ex.Message}", ConsoleColor.Red); return(ExitCodes.Fatal); } return(ExitCodes.OK); }
public static int Main(string[] args) { try { var logger = new Logger(); if (args.Length == 1) { string packPath = args[0]; WriteLine($"Parsing {packPath}", ConsoleColor.Cyan); var basePack = LanguagePack.LoadFromFile(packPath, logger); } else if (args.Length == 2) { string basePackPath = args[0]; string translationPackPath = args[1]; var basePack = LanguagePack.LoadFromFile(basePackPath, new FakeLogger()); WriteLine($"Parsing {translationPackPath}", ConsoleColor.Cyan); var translationPack = LanguagePack.LoadFromFile(translationPackPath, logger); int presentEntries = 0; int totalEntries = basePack.Entries.Count; foreach (var kvp in basePack.Entries) { int id = kvp.Key; string baseString = kvp.Value.Text; if (translationPack.Entries.ContainsKey(id)) { presentEntries++; } else { string message = String.Format(" warning: No string for STR_{0:0000}: {1}", id, baseString); WriteLine(message, ConsoleColor.Yellow); } } int progressPercent = (int)Math.Floor(presentEntries / (totalEntries / 100.0f)); string finalMessage = String.Format(" info: {0} / {1} ({2}%) strings present", presentEntries, totalEntries, progressPercent); WriteLine(finalMessage, ConsoleColor.Cyan); } else { PrintUsageInfo(); return(ExitCodes.UsageInfo); } if (logger.HasErrors) { Console.WriteLine(); return(ExitCodes.Errors); } else if (logger.HasWarnings) { Console.WriteLine(); return(ExitCodes.Warnings); } } catch (IOException ex) { WriteLine($"Unable to open file: {ex.Message}", ConsoleColor.Red); return(ExitCodes.Fatal); } return(ExitCodes.OK); }