예제 #1
0
        public static IList <TranslationItemWithCategory> LoadNeutralItems()
        {
            Translation neutralTranslation = new Translation();

            try
            {
                //Set language to neutral to get neutral translations
                GitCommands.AppSettings.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.AppSettings.CurrentTranslation = null;
            }

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

            return(neutralItems);
        }
        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;
            }
        }
예제 #3
0
        public static IDictionary <string, List <TranslationItemWithCategory> > LoadNeutralItems()
        {
            IDictionary <string, TranslationFile> neutralTranslation = new Dictionary <string, TranslationFile>();

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

                var translatableTypes = TranslationUtl.GetTranslatableTypes();
                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);
                            }
                            IDisposable disposable = obj as IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                    }
                    finally
                    {
                        translation.Sort();
                        neutralTranslation[types.Key] = translation;
                    }
                }
            }
            finally
            {
                //Restore translation
                GitCommands.AppSettings.CurrentTranslation = null;
            }

            return(GetItemsDictionary(neutralTranslation));
        }
예제 #4
0
        private void FillNeutralTranslation()
        {
            try
            {
                //Set language to neutral to get neutral translations
                GitCommands.AppSettings.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.AppSettings.CurrentTranslation = null;
                progressBar.Visible = false;
            }
        }