Пример #1
0
        public static void ExportFile(Args.ExportFileCommand cmd)
        {
            var muidb = new MuiDBFile(cmd.MuiDB);

            switch (cmd.Type.ToLowerInvariant())
            {
            case "resx":
                var options = cmd.NoComments ? MuiDBFile.SaveOptions.SkipComments : MuiDBFile.SaveOptions.None;
                muidb.ExportResX(cmd.Out, cmd.Lang, options);
                Verbose(cmd, $"Exporting language '{cmd.Lang}' into file '{cmd.Out}'");
                break;

            case "xliff":
                throw new Exception("XLIFF export is not implemented, yet");

            default:
                throw new Exception($"Unknown format: {cmd.Type}");
            }
        }
Пример #2
0
        public static void Export(Args.ExportCommand cmd)
        {
            string dir = GetFullNormalizedDirectory(cmd.MuiDB);

            foreach (var file in GetMatchingFiles(dir, Path.GetFileName(cmd.MuiDB)))
            {
                var muidb = new MuiDBFile(file);
                if (!muidb.TargetFiles.Any())
                {
                    throw new InvalidOperationException($"'{file}' does not contain any files to export");
                }

                Verify(new Args.ValidateCommand()
                {
                    MuiDB = file, Verbose = cmd.Verbose, ReFormat = cmd.ReFormat
                });

                Verbose(cmd, $"Exporting from file '{file}'");

                foreach (var target in muidb.TargetFiles)
                {
                    var targetFile = Path.Combine(dir, target.Name);
                    Verbose(cmd, $"Exporting language '{target.Lang}' into file '{targetFile}'");
                    muidb.ExportResX(targetFile, target.Lang, MuiDBFile.SaveOptions.None);

                    var d = target.Designer;
                    if (d != null)
                    {
                        try
                        {
                            var codeNamespace = cmd.CodeNamespace ?? d.Namespace;
                            Verbose(cmd, $"Generating '{d.ClassName}.Designer.cs' from '{targetFile}' with namespace={codeNamespace} and internal={d.IsInternal}");
                            ResX.ResXFile.GenerateDesignerFile(targetFile, d.ClassName, codeNamespace, d.IsInternal);
                        }
                        catch (Exception e)
                        {
                            throw new Exception($"Generating designer file for '{file}' failed", e);
                        }
                    }
                }
            }
        }