Beispiel #1
0
        /*
         * /// <summary>
         * /// set client locale
         * /// </summary>
         * /// <param name="locale"></param>
         * public static void SetLocale(string locale)
         * {
         *  if (_service != null)
         *      _service.SetLocale(locale);
         * }
         */

        /// <summary>
        /// 切換語系 for view
        /// </summary>
        /// <param name="locale"></param>
        public static void SetCulture(string locale)
        {
            if (CultureInfo.CurrentCulture.Name == locale)
            {
                return;
            }

            //set default language, .net 4.5後設定DefaultThread即可
            var culture = new CultureInfo(locale);

            CultureInfo.DefaultThreadCurrentCulture   = culture;
            CultureInfo.DefaultThreadCurrentUICulture = culture;

            //Thread.CurrentThread.CurrentCulture = culture;
            //Thread.CurrentThread.CurrentUICulture = culture;

            if (_localeService != null)
            {
                _localeService.SetLocale(locale);
            }
        }