Example #1
0
        public void Run()
        {
            // Now we only download new translations that don't exist due to BING Quota issues
            // NOTE: Translate will add/delete individual translations for any files that already exist, so DELETE the file to create fresh translation files
            for (int i = 0; i < _languageCodes.Length; i++)
            {
                _translateThreads[i] = new Translate(_localisationPath, _languageCodes[i], _languageNames[i], i+1);
                if (_languageCodes[i] != "en")
                {
                    WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + "Starting translations...", i + 1,ConsoleColor.White);
                    Thread workerThread = _translateThreads[i].TranslateFile();

                    // Workaround code start
                    // This code limits to one thread download at a time
                    // This is required since BING reports us sending data too fast and blocks the IP - workaround
                    while (workerThread.ThreadState != ThreadState.Stopped)
                    {
                        if (!_translateThreads[i].QuotaError) // If we are in Quota error don't overwrite the text
                            WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + _translateThreads[i].Progress + " translations. Downloaded " + _translateThreads[i].Downloaded + " Existing " + _translateThreads[i].Replaced + " Manual " + _translateThreads[i].Manual + " Duplicate " + _translateThreads[i].Duplicate, i + 1, ConsoleColor.Blue);
                        Thread.Sleep(200);
                    }
                    // End of workaround code
                }
                else
                    WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + "Master file, no translation required", i + 1, ConsoleColor.DarkYellow);
            }

            // Wait for all thread to complete
            Thread.Sleep(300); // Give the thread some time to start
            bool done = false;
            while (!done)
            {
                done = true;
                for (int i = 0; i < _languageCodes.Length; i++)
                {
                    if (_translateThreads[i].Active)
                    {
                        if (!_translateThreads[i].QuotaError) // If we are in Quota error don't overwrite the text
                            WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + _translateThreads[i].Progress + " translations. Downloaded " + _translateThreads[i].Downloaded + " Existing " + _translateThreads[i].Replaced + " Manual " + _translateThreads[i].Manual + " Duplicate " + _translateThreads[i].Duplicate, i + 1, ConsoleColor.Blue);
                        done = false;
                    }
                }
                Thread.Sleep(200);
            }

            // Handle the chinese exception, select traditional
            string chineseFileBase = Path.Combine(_localisationPath, "zh");
            if (File.Exists(chineseFileBase + "-CHT.txt")) File.Copy(chineseFileBase + "-CHT.txt",chineseFileBase + ".txt",true);

            Console.BackgroundColor = ConsoleColor.Green;
            WriteStatus("GenLocalized MCEBuddy - DONE!!! press any key to continue...", 0, ConsoleColor.Yellow);
            ConsoleKeyInfo cki = Console.ReadKey(true);
        }
Example #2
0
        public void Run()
        {
            // Now we only download new translations that don't exist due to BING Quota issues
            // NOTE: Translate will add/delete individual translations for any files that already exist, so DELETE the file to create fresh translation files
            for (int i = 0; i < _languageCodes.Length; i++)
            {
                _translateThreads[i] = new Translate(_localisationPath, _languageCodes[i], _languageNames[i], i + 1);
                if (_languageCodes[i] != "en")
                {
                    WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + "Starting translations...", i + 1, ConsoleColor.White);
                    Thread workerThread = _translateThreads[i].TranslateFile();

                    // Workaround code start
                    // This code limits to one thread download at a time
                    // This is required since BING reports us sending data too fast and blocks the IP - workaround
                    while (workerThread.ThreadState != ThreadState.Stopped)
                    {
                        if (!_translateThreads[i].QuotaError) // If we are in Quota error don't overwrite the text
                        {
                            WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + _translateThreads[i].Progress + " translations. Downloaded " + _translateThreads[i].Downloaded + " Existing " + _translateThreads[i].Replaced + " Manual " + _translateThreads[i].Manual + " Duplicate " + _translateThreads[i].Duplicate, i + 1, ConsoleColor.Blue);
                        }
                        Thread.Sleep(200);
                    }
                    // End of workaround code
                }
                else
                {
                    WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + "Master file, no translation required", i + 1, ConsoleColor.DarkYellow);
                }
            }

            // Wait for all thread to complete
            Thread.Sleep(300); // Give the thread some time to start
            bool done = false;

            while (!done)
            {
                done = true;
                for (int i = 0; i < _languageCodes.Length; i++)
                {
                    if (_translateThreads[i].Active)
                    {
                        if (!_translateThreads[i].QuotaError) // If we are in Quota error don't overwrite the text
                        {
                            WriteStatus(_languageCodes[i] + " (" + _languageNames[i] + ")" + " -> " + _translateThreads[i].Progress + " translations. Downloaded " + _translateThreads[i].Downloaded + " Existing " + _translateThreads[i].Replaced + " Manual " + _translateThreads[i].Manual + " Duplicate " + _translateThreads[i].Duplicate, i + 1, ConsoleColor.Blue);
                        }
                        done = false;
                    }
                }
                Thread.Sleep(200);
            }

            // Handle the chinese exception, select traditional
            string chineseFileBase = Path.Combine(_localisationPath, "zh");

            if (File.Exists(chineseFileBase + "-CHT.txt"))
            {
                File.Copy(chineseFileBase + "-CHT.txt", chineseFileBase + ".txt", true);
            }

            Console.BackgroundColor = ConsoleColor.Green;
            WriteStatus("GenLocalized MCEBuddy - DONE!!! press any key to continue...", 0, ConsoleColor.Yellow);
            ConsoleKeyInfo cki = Console.ReadKey(true);
        }