Пример #1
0
        /// <summary>
        /// 设置区域信息
        /// </summary>
        /// <param name="cultureConfigFile">语言配置文件路径</param>
        public void SetCulture(string cultureConfigFile)
        {
            System.Xml.XPath.XPathDocument  doc       = new System.Xml.XPath.XPathDocument(ZeroConfigSystem.Instance.SysCultureFile);
            System.Xml.XPath.XPathNavigator navigator = doc.CreateNavigator();
            bool enableSetCulture = false;

            if (navigator.SelectSingleNode("/CultureInfo/EnableSetCulture") != null)
            {
                string value = navigator.SelectSingleNode("/CultureInfo/EnableSetCulture").Value;
                if (!string.IsNullOrEmpty(value))
                {
                    enableSetCulture = value.Equals("1");
                }
            }

            this.EnableSetLanguage    = enableSetCulture;
            this.SystemDefaultCulture = "en-US";
            if (navigator.SelectSingleNode("/CultureInfo/Culture") != null)
            {
                this.SystemDefaultCulture = navigator.SelectSingleNode("/CultureInfo/Culture").Value;
                if (string.IsNullOrEmpty(this.SystemDefaultCulture))
                {
                    this.SystemDefaultCulture = "en-US";
                }
            }

            this.CurrentCulture  = this.SystemDefaultCulture;
            this.IsCustomCulture = false;
            if (File.Exists(cultureConfigFile))
            {
                string customCulture = IniFileHelper.ReadINIValue(cultureConfigFile, "Langauge", "Default");
                if (!string.IsNullOrEmpty(customCulture))
                {
                    CurrentCulture = customCulture;
                }

                string enableCustomCulture = IniFileHelper.ReadINIValue(cultureConfigFile, "Langauge", "EnableCustomCulture");
                if (!string.IsNullOrEmpty(enableCustomCulture))
                {
                    this.IsCustomCulture = enableCustomCulture.Equals("1");
                }
            }

            SetCulture(CurrentCulture, this.IsCustomCulture);
        }