Exemplo n.º 1
0
        private static void UpdateAllTranslations()
        {
            Cursor.Current = Cursors.WaitCursor;
            var neutralItems = TranslationHelpers.LoadNeutralItems();

            var translationsNames = Translator.GetAllTranslations();

            foreach (var name in translationsNames)
            {
                Translation translation = Translator.GetTranslation(name);
                List <TranslationItemWithCategory> translateItems = TranslationHelpers.LoadTranslation(translation, neutralItems);
                string filename = Path.Combine(Translator.GetTranslationDir(), name + ".xml");
                TranslationHelpers.SaveTranslation(translation.LanguageCode, translateItems, filename);
            }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 2
0
        private static void UpdateAllTranslations()
        {
            using (new WaitCursorScope())
            {
                var    neutralItems = TranslationHelpers.LoadNeutralItems();
                string filename     = Path.Combine(Translator.GetTranslationDir(), "English.xlf");
                TranslationHelpers.SaveTranslation(null, neutralItems, filename);

                var translationsNames = Translator.GetAllTranslations();
                foreach (var name in translationsNames)
                {
                    var translation    = Translator.GetTranslation(name);
                    var translateItems = TranslationHelpers.LoadTranslation(translation, neutralItems);
                    filename = Path.Combine(Translator.GetTranslationDir(), name + ".xlf");
                    TranslationHelpers.SaveTranslation(translation.First().Value.TargetLanguage, translateItems, filename);
                }
            }
        }
Exemplo n.º 3
0
 private void SaveAs()
 {
     using (var fileDialog =
                new SaveFileDialog
     {
         Title = _saveAsText.Text,
         FileName = translations.Text + ".xlf",
         Filter = _saveAsTextFilter.Text + "|*.xlf",
         DefaultExt = ".xlf",
         AddExtension = true
     })
     {
         if (fileDialog.ShowDialog(this) == DialogResult.OK)
         {
             TranslationHelpers.SaveTranslation(GetSelectedLanguageCode(), _translationItems, fileDialog.FileName);
             _changesMade = false;
         }
     }
 }
Exemplo n.º 4
0
        private static void UpdateAllTranslations()
        {
            Cursor.Current = Cursors.WaitCursor;
            var    neutralItems = TranslationHelpers.LoadNeutralItems();
            string filename     = Path.Combine(Translator.GetTranslationDir(), "English.xlf");

            TranslationHelpers.SaveTranslation(null, neutralItems, filename);

            var translationsNames = Translator.GetAllTranslations();

            foreach (var name in translationsNames)
            {
                var translation    = Translator.GetTranslation(name);
                var translateItems = TranslationHelpers.LoadTranslation(translation, neutralItems);
                filename = Path.Combine(Translator.GetTranslationDir(), name + ".xlf");
                TranslationHelpers.SaveTranslation(translation.First().Value.LanguageCode, translateItems, filename);
            }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 5
0
        private void LoadTranslation()
        {
            if (translation != null)
            {
                IEnumerable <TranslationItemWithCategory> neutralItems =
                    (from translationCategory in neutralTranslation.TranslationCategories
                     from translationItem in translationCategory.Body.TranslationItems
                     select new TranslationItemWithCategory(translationCategory.Name, translationItem));
                translationItems = TranslationHelpers.LoadTranslation(translation, neutralItems);
            }
            else
            {
                List <TranslationItemWithCategory> neutralItems =
                    (from translationCategory in neutralTranslation.TranslationCategories
                     from translationItem in translationCategory.Body.TranslationItems
                     select new TranslationItemWithCategory(translationCategory.Name, translationItem.Clone())).ToList();
                translationItems = neutralItems;
            }

            UpdateProgress();
        }
Exemplo n.º 6
0
        private void LoadTranslation()
        {
            if (_translation.Count != 0)
            {
                var items = TranslationHelpers.GetItemsDictionary(_translation);
                translationItems = TranslationHelpers.LoadTranslation(_translation, items);
            }
            else
            {
                var neutralItems = new Dictionary <string, List <TranslationItemWithCategory> >();
                foreach (var pair in _neutralTranslation)
                {
                    var list = from item in pair.Value.TranslationCategories
                               from translationItem in item.Body.TranslationItems
                               select new TranslationItemWithCategory(item.Name, translationItem.Clone());
                    neutralItems.Add(pair.Key, list.ToList());
                }
                translationItems = neutralItems;
            }

            UpdateProgress();
        }
Exemplo n.º 7
0
        private static void UpdateAllTranslations()
        {
            using (new WaitCursorScope())
            {
                // we will be instantiating a number of forms using their default .ctors
                // this would lead to InvalidOperationException thrown in GitModuleForm()
                // set the flag that will stop this from happening
                GitModuleForm.IsUnitTestActive = true;

                var    neutralItems = TranslationHelpers.LoadNeutralItems();
                string filename     = Path.Combine(Translator.GetTranslationDir(), "English.xlf");
                TranslationHelpers.SaveTranslation(null, neutralItems, filename);

                var translationsNames = Translator.GetAllTranslations();
                foreach (var name in translationsNames)
                {
                    var translation    = Translator.GetTranslation(name);
                    var translateItems = TranslationHelpers.LoadTranslation(translation, neutralItems);
                    filename = Path.Combine(Translator.GetTranslationDir(), name + ".xlf");
                    TranslationHelpers.SaveTranslation(translation.First().Value.TargetLanguage, translateItems, filename);
                }
            }
        }
Exemplo n.º 8
0
        private static void Main()
        {
            // This form created for obtain UI synchronization context only
            using (new Form())
            {
                // Store the shared JoinableTaskContext
                ThreadHelper.JoinableTaskContext = new JoinableTaskContext();
            }

            // force load into the appdomain
            using (BugReportForm dummy = new())
            {
            }

            // required for translation
            PluginRegistry.Initialize();

            // we will be instantiating a number of forms using their default .ctors
            // this would lead to InvalidOperationException thrown in GitModuleForm()
            // set the flag that will stop this from happening
            GitModuleForm.IsUnitTestActive = true;

            var    neutralItems = TranslationHelpers.LoadNeutralItems();
            string filename     = Path.Combine(Translator.GetTranslationDir(), "English.xlf");

            TranslationHelpers.SaveTranslation(null, neutralItems, filename);

            var translationsNames = Translator.GetAllTranslations();

            foreach (var name in translationsNames)
            {
                var translation    = Translator.GetTranslation(name);
                var translateItems = TranslationHelpers.LoadTranslation(translation, neutralItems);
                filename = Path.Combine(Translator.GetTranslationDir(), name + ".xlf");
                TranslationHelpers.SaveTranslation(translation.First().Value.TargetLanguage, translateItems, filename);
            }
        }