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 (Exception)
                    {
                        Trace.WriteLine("Problem with class: " + type.FullName);
                        throw;
                    }
                }

                testTranslation[types.Key] = tranlation;
            }
        }
        public static IList <TranslationItemWithCategory> LoadNeutralItems()
        {
            Translation neutralTranslation = new Translation();

            try
            {
                //Set language to neutral to get neutral translations
                GitCommands.Settings.CurrentTranslation = "";

                List <Type> translatableTypes = TranslationUtl.GetTranslatableTypes();
                foreach (Type type in translatableTypes)
                {
                    ITranslate obj = TranslationUtl.CreateInstanceOfClass(type) as ITranslate;
                    if (obj != null)
                    {
                        obj.AddTranslationItems(neutralTranslation);
                    }
                }
            }
            finally
            {
                neutralTranslation.Sort();

                //Restore translation
                GitCommands.Settings.CurrentTranslation = null;
            }

            IList <TranslationItemWithCategory> neutralItems =
                (from translationCategory in neutralTranslation.GetTranslationCategories()
                 from translationItem in translationCategory.GetTranslationItems()
                 select new TranslationItemWithCategory(translationCategory.Name, translationItem)).ToList();

            return(neutralItems);
        }
 public object CreateInstanceOfClass(Type type)
 {
     if (type == GetType())
     {
         return(this);
     }
     else
     {
         return(TranslationUtl.CreateInstanceOfClass(type));
     }
 }
Beispiel #4
0
        private void FillNeutralTranslation()
        {
            try
            {
                //Set language to neutral to get neutral translations
                GitCommands.Settings.CurrentTranslation = "";

                List <Type> translatableTypes = TranslationUtl.GetTranslatableTypes();
                progressBar.Maximum = translatableTypes.Count;
                progressBar.Visible = true;

                for (int index = 0; index < translatableTypes.Count; index++)
                {
                    Type       type = translatableTypes[index];
                    ITranslate obj  = TranslationUtl.CreateInstanceOfClass(type) as ITranslate;
                    if (obj != null)
                    {
                        obj.AddTranslationItems(neutralTranslation);
                    }

                    progressBar.Value = index;
                    if (index % 10 == 0)
                    {
                        Update();
                    }
                }
            }
            finally
            {
                neutralTranslation.Sort();

                //Restore translation
                GitCommands.Settings.CurrentTranslation = null;
                progressBar.Visible = false;
            }
        }
        public void CreateInstanceOfClass()
        {
            // just reference to GitUI
            MouseWheelRedirector.Active = true;

            List <Type> translatableTypes = TranslationUtl.GetTranslatableTypes();

            var testTranslation = new Translation();

            foreach (Type type in translatableTypes)
            {
                try
                {
                    ITranslate obj = TranslationUtl.CreateInstanceOfClass(type) as ITranslate;
                    obj.AddTranslationItems(testTranslation);
                    obj.TranslateItems(testTranslation);
                }
                catch (System.Exception)
                {
                    Trace.WriteLine("Problem with class: " + type.FullName);
                    throw;
                }
            }
        }