static int RunAddSentence(AddSentenceOptions opts)
        {
            var manager = new TranslationManager
            {
                ConsoleMessage = (x) => ShowMessage(x)
            };

            manager.Initialize(opts.Filename);

            var retVal = manager.AddSentence(opts.ArrayName, opts.Reference, opts.Sentence);

            return(retVal ? 0 : 1);
        }
        static int RunAddLanguage(AddLanguageOptions opts)
        {
            var retVal = 0;

            CheckInputFileExists();

            var manager = new TranslationManager();

            manager.Initialize(opts.Filename);
            manager.ConsoleMessage = (x) => ShowMessage(x);

            var stopGeneration = false;
            var generateScript = false;

            while (!stopGeneration)
            {
                ShowMessage("Starting generation.", ConsoleColor.DarkYellow);
                List <string> errors = new List <string>();
                try
                {
                    errors = manager.AddTranslation(opts.Reference, opts.Language, opts.IsoCode, opts.Continue);
                }
                catch (Exception ex)
                {
                    stopGeneration = true;
                    generateScript = false;
                    retVal         = 1;
                    errors.Add(ex.Message);
                }

                if (errors.Count == 0)
                {
                    retVal         = 0;
                    stopGeneration = true;
                    generateScript = true;
                }
                else
                {
                    ShowErrors(errors);
                    // Wait 100 seconds
                    stopGeneration = (!WaitSeconds(100));
                    opts.Continue  = true;
                    retVal         = 1;
                    generateScript = false;
                }
            }

            return(retVal);
        }
        static int RunFixes(FixesOptions opts)
        {
            var manager = new TranslationManager
            {
                ConsoleMessage = (x) => ShowMessage(x)
            };

            manager.Initialize(opts.Filename);

            ShowMessage($"Applying fixes on {opts.Filename}");

            manager.ApplyFixes();

            return(0);
        }
        static int RunCreateScript(CreateScriptOption opts)
        {
            var manager = new TranslationManager
            {
                ConsoleMessage = (x) => ShowMessage(x)
            };

            manager.Initialize(opts.Filename);

            ShowMessage($"Generating script {opts.ScriptFilename}");

            var retVal = RunScriptCreation(manager, opts); // TODO: use on Add translation too

            if (retVal == 0)
            {
                ShowMessage("Script generated.");
            }

            return(retVal);
        }
 static int RunScriptCreation(TranslationManager manager, CreateScriptOption opts)
 => manager?.GenerateScript(opts.ScriptFilename, opts.Version) == true ? 0 : 1;