Пример #1
0
        /// <summary>Gets an array of all the Installer resource languages in this installer.</summary>
        public static InstallerResourceLanguage[] GetAvailableLanguages()
        {
            if (_availableLanguages == null)
            {
                Assembly thisAssembly = Assembly.GetExecutingAssembly();
                String[] names        = thisAssembly.GetManifestResourceNames();

                List <InstallerResourceLanguage> langs = new List <InstallerResourceLanguage>();

                foreach (String name in names)
                {
                    if (name.StartsWith("Anolis.Installer.Resources", StringComparison.Ordinal))
                    {
                        InstallerResourceLanguage lang = new InstallerResourceLanguage(name);
                        langs.Add(lang);
                    }
                    else if (name.StartsWith("Anolis.Installer.Customizer", StringComparison.Ordinal))
                    {
                        _customizerName = name;
                    }
                }

                _availableLanguages = langs.ToArray();

                //Array.Sort( _availableLanguages, (x,y) => x.LcidName.CompareTo( y.LcidName ) );
                Array.Sort(_availableLanguages, (x, y) => x.LanguageName.CompareTo(y.LanguageName));
            }

            return(_availableLanguages);
        }
Пример #2
0
        static InstallerResources()
        {
            InstallerResourceLanguage[] langs = GetAvailableLanguages();

            CultureInfo current = CultureInfo.CurrentCulture.Parent;

            foreach (InstallerResourceLanguage lang in langs)
            {
                if (lang.LcidName == "en")
                {
                    _english = lang;
                }
                if (current.Name == lang.LcidName)
                {
                    _currentLanguage = lang;
                }
                if (_english != null && _currentLanguage != null)
                {
                    break;
                }
            }

            if (_english == null)
            {
                throw new AnolisException("Couldn't load fallback language.");
            }

            if (_currentLanguage == null)
            {
                _currentLanguage = _english;
            }

            /////////////////////////////////////////////

            if (_customizerName != null)
            {
                // _customizerName is set by GetAvailableLanguages as a side-effect
                _customizer = new InstallerCustomizer(_customizerName);
            }
        }