public void CreateInstanceOfClass()
        {
            // just reference to GitUI
            MouseWheelRedirector.Active = true;

            var translatableTypes = TranslationUtl.GetTranslatableTypes();

            var testTranslation = new Dictionary<string, TranslationFile>();

            foreach (var types in translatableTypes)
            {
                var tranlation = new TranslationFile();
                foreach (Type type in types.Value)
                {
                    try
                    {
                        ITranslate obj = TranslationUtl.CreateInstanceOfClass(type) as ITranslate;
                        obj.AddTranslationItems(tranlation);
                        obj.TranslateItems(tranlation);
                    }
                    catch (System.Exception)
                    {
                        Trace.WriteLine("Problem with class: " + type.FullName);
                        throw;
                    }
                }
                testTranslation[types.Key] = tranlation;
            }
        }
Example #2
0
        public static void Serialize(TranslationFile translation, string path)
        {
            using TextWriter tw = new StreamWriter(path, false);
            var serializer = new XmlSerializer(typeof(TranslationFile));

            serializer.Serialize(tw, translation);
        }
 public static void Serialize(TranslationFile translation, string path)
 {
     using (TextWriter tw = new StreamWriter(path, false))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(TranslationFile));
         serializer.Serialize(tw, translation);
     }
 }
Example #4
0
        private void FillNeutralTranslation()
        {
            try
            {
                //Set language to neutral to get neutral translations
                GitCommands.AppSettings.CurrentTranslation = "";

                var translatableTypes = TranslationUtl.GetTranslatableTypes();
                progressBar.Maximum = translatableTypes.Sum(types => types.Value.Count);
                progressBar.Visible = true;

                int index = 0;
                foreach (var types in translatableTypes)
                {
                    var translation = new TranslationFile();
                    try
                    {
                        foreach (Type type in types.Value)
                        {
                            ITranslate obj = TranslationUtl.CreateInstanceOfClass(type) as ITranslate;
                            if (obj != null)
                                obj.AddTranslationItems(translation);

                            progressBar.Value = index;
                            index++;
                            if (index % 10 == 0)
                                Update();
                        }
                    }
                    finally
                    {
                        translation.Sort();
                        _neutralTranslation[types.Key] = translation;
                    }
                }
            }
            finally
            {
                //Restore translation
                GitCommands.AppSettings.CurrentTranslation = null;
                progressBar.Visible = false;
            }
        }