protected override void ProcessRecord() { var fullInputPath = InputResourceFile; if (!Path.IsPathRooted(InputResourceFile)) { fullInputPath = Resolve(InputResourceFile); } var fullOutputPath = OutputResourceFile; if (!Path.IsPathRooted(OutputResourceFile)) { fullOutputPath = Resolve(OutputResourceFile); } if(!File.Exists(fullInputPath)) { WriteObject(string.Format("input file does not exist: {0}", fullOutputPath)); WriteObject("closing..."); return; } WriteObject("Pseudoizer: Adapted from MSDN BugSlayer 2004-Apr i18n Article"); WriteObject(string.Format(" - generating resource file from {0}", fullInputPath)); WriteObject(string.Format(" - output to {0}", fullOutputPath)); var psuedoizer = new Psuedoizer(); psuedoizer.Run(fullInputPath, fullOutputPath); WriteObject(string.Format("Psuedoizer completed successfully")); }
protected override void ProcessRecord() { var fullInputPath = InputResourceFile; if (!Path.IsPathRooted(InputResourceFile)) { fullInputPath = Resolve(InputResourceFile); } var fullOutputPath = OutputResourceFile; if (!Path.IsPathRooted(OutputResourceFile)) { fullOutputPath = Resolve(OutputResourceFile); } if (!File.Exists(fullInputPath)) { WriteObject(string.Format("input file does not exist: {0}", fullOutputPath)); WriteObject("closing..."); return; } WriteObject("Pseudoizer: Adapted from MSDN BugSlayer 2004-Apr i18n Article"); WriteObject(string.Format(" - generating resource file from {0}", fullInputPath)); WriteObject(string.Format(" - output to {0}", fullOutputPath)); var psuedoizer = new Psuedoizer(); psuedoizer.Run(fullInputPath, fullOutputPath); WriteObject(string.Format("Psuedoizer completed successfully")); }
protected override void ProcessRecord() { this.WriteObject("Psuedoizer: Adapted from MSDN BugSlayer 2004-Apr i18n Article"); this.WriteObject(string.Format(" - generating resource file from {0}", InputResourceFile)); this.WriteObject(string.Format(" - output to {0}", OutputResourceFile)); Psuedoizer psuedoizer = new Psuedoizer(); psuedoizer.Run(InputResourceFile, OutputResourceFile); this.WriteObject(string.Format("Psuedoizer completed successfully")); }
/// <summary> /// The main entry point for the application. /// </summary> public void Run(string fileName, string fileSaveName) { try { // Open the input file. ResXResourceReader reader = new ResXResourceReader(fileName); // Get the enumerator. If this throws an ArguementException // it means the file is not a .RESX file. IDictionaryEnumerator enumerator = reader.GetEnumerator(); // Allocate the list for this instance. SortedList textResourcesList = new SortedList(); // Run through the file looking for only true text related // properties and only those with values set. foreach (DictionaryEntry dic in reader) { // Only consider this entry if the value is something. if (null != dic.Value) { // Is this a System.String. if ("System.String" == dic.Value.GetType().ToString()) { String KeyString = dic.Key.ToString(); // Make sure the key name does not start with the // "$" or ">>" meta characters and is not an empty // string. if ((false == KeyString.StartsWith(">>")) && (false == KeyString.StartsWith("$")) && ("" != dic.Value.ToString())) { // We've got a winner. textResourcesList.Add(dic.Key, dic.Value); } // Special case the Windows Form "$this.Text" or // I don't get the form titles. if (0 == String.Compare(KeyString, "$this.Text")) { textResourcesList.Add(dic.Key, dic.Value); } } } } // It's entirely possible that there are no text strings in the // .ResX file. if (textResourcesList.Count > 0) { if (null != fileSaveName) { // Create the new file. ResXResourceWriter writer = new ResXResourceWriter(fileSaveName); foreach (DictionaryEntry textdic in textResourcesList) { writer.AddResource(textdic.Key.ToString(), Psuedoizer.ConvertToFakeInternationalized(textdic.Value.ToString())); } writer.Generate(); writer.Close(); Console.WriteLine("Converted " + textResourcesList.Count + " text resource(s)."); } } else { Console.Write("WARNING: No text resources found in " + fileName); System.Environment.Exit(2); } } catch (Exception e) { Console.Write(e.ToString()); System.Environment.Exit(1); } }