示例#1
0
        Language LoadLanguages()
        {
            LanguageLoader.LoadLanguages(GlobalSettings.GetDataURI("Languages"));

            Language useLanguage = null;

            try
            {
                // stage 1 (prelim): if no language, see if our languages contain it
                if (string.IsNullOrEmpty(GlobalSettings.LanguageFile))
                {
                    useLanguage =
                        LanguageLoader.FindLanguage((CultureInfo.CurrentUICulture.IsNeutralCulture == false)
                                                                                                                ? CultureInfo.CurrentUICulture.Parent.Name
                                                                                                                : CultureInfo.CurrentUICulture.Name);
                }

                // stage 2: load from last used language
                if (useLanguage == null)
                {
                    useLanguage = LanguageLoader.FindLanguage(GlobalSettings.LanguageFile);
                }

                // stage 3: use English file, if it exists
                if (useLanguage == null)
                {
                    useLanguage = LanguageLoader.FindLanguage("English");
                }
            }
            catch
            {
            }
            finally
            {
                // stage 4: fallback to built-in English file
                if (useLanguage == null)
                {
                    Program.Context.SplashForm.Invoke((Action)(() => MessageBox.Show(this, "For some reason, the default language files were missing or failed to load (did you extract?) - we'll supply you with a base language of English just so you know what you're doing!")));
                    useLanguage = LanguageLoader.LoadDefault();
                }
            }

            return(useLanguage);
        }