Example #1
0
        private static void Text2Resx(string dir, string outdir, string ns, string sep, string dict, int emptyType)
        {
            var filepaths = GetAllLanguageDictionaries(dict, dir, ".txt");

            foreach (var path in filepaths)
            {
                var resxGen = new ResxGenerator();
                var records = TextParser.Parse(path, sep);
                if (records == null || records.Count == 0)
                {
                    Console.WriteLine($"No record found in {path}. pass");
                    continue;
                }
                string filebase = Path.GetFileNameWithoutExtension(path);
                Console.WriteLine($"Dictionary {filebase} parsed");
                if (outdir == "")
                {
                    outdir = Path.GetDirectoryName(path);
                }
                var resxPath = Path.Combine(outdir, $"{filebase}.resx");
                resxGen.AddRecords(records, emptyType);
                resxGen.Save(resxPath);
                Console.WriteLine($"{resxPath} saved");
                if (ShouldSaveDesignerClass(dict, filebase))
                {
                    resxGen.SaveDesignerClass(outdir, filebase, ns);
                    Console.WriteLine($"{filebase}.Designer.cs saved");
                }
            }
        }
Example #2
0
        private static void Resx2Text(string dir, string outdir, string sep, string dict, bool extraLine)
        {
            var filepaths = GetAllLanguageDictionaries(dict, dir, ".resx");

            foreach (var path in filepaths)
            {
                var records = ResxGenerator.ReadRecords(path);
                if (records == null || records.Count == 0)
                {
                    Console.WriteLine($"no record found in {path}. pass");
                    continue;
                }
                string filebase = Path.GetFileNameWithoutExtension(path);
                Console.WriteLine($"Dictionary {filebase} parsed");
                if (outdir == "")
                {
                    outdir = Path.GetDirectoryName(path);
                }
                var textPath = Path.Combine(outdir, $"{filebase}.txt");
                TextParser.Dump(records, textPath, sep, extraLine);
                Console.WriteLine($"{textPath} saved");
            }
        }