コード例 #1
0
        public static UILanguage CreateDefaultUILanguage()
        {
            UILanguage language = new UILanguage();

            language.isDefault = true;

            return(language);
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            UILanguage other = obj as UILanguage;

            if (other == null)
            {
                return(false);
            }
            else if (this.IsDefault && other.IsDefault)
            {
                return(true);
            }
            else if (!this.IsDefault && !other.IsDefault)
            {
                return(this.culture.Equals(other.culture));
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        static UILanguage()
        {
            // Load localization resources
            Assembly assembly    = Assembly.GetExecutingAssembly();
            string   resourceDir = Path.GetDirectoryName(assembly.Location);

            // Search for localized cultures
            try
            {
                DirectoryInfo   resource    = new DirectoryInfo(resourceDir);
                DirectoryInfo[] directories = resource.GetDirectories("*",
                                                                      SearchOption.TopDirectoryOnly);
                availableCultures = new List <UILanguage>(directories.Length + 2);

                foreach (DirectoryInfo directory in directories)
                {
                    if (directory.Name != "Plugins" && directory.Name != "Templates")
                    {
                        string     cultureName = directory.Name;
                        UILanguage language    = CreateUILanguage(cultureName);
                        if (language != null)
                        {
                            availableCultures.Add(language);
                        }
                    }
                }
            }
            catch
            {
                availableCultures = new List <UILanguage>(2);
            }

            availableCultures.Add(CreateDefaultUILanguage());
            availableCultures.Add(CreateUILanguage("en"));
            availableCultures.Sort(delegate(UILanguage c1, UILanguage c2)
            {
                return(c1.Name.CompareTo(c2.Name));
            });
        }