Example #1
0
        protected void LocaleKey_Changed(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(localeKeys.SelectedValue);

            var cookieName = ConfigTool.GetAppSettings("Localization.UserLocale.CookieName", "_LOCALE_KEY_");

            CookieTool.Set(cookieName, localeKeys.SelectedValue);

            Response.Redirect(Request.RawUrl);
        }
        /// <summary>
        /// CurrentCulture를 지정한 culture로 설정합니다.
        /// </summary>
        /// <param name="culture"></param>
        private static void SetCurrentCulture(CultureInfo culture)
        {
            // UICulture = 'ko'
            // Culture = 'ko-KR'

            Thread.CurrentThread.CurrentUICulture = culture ?? Thread.CurrentThread.CurrentUICulture;

            // NOTE: Culture는 neutral culture를 지정할 수 없고, SpecificCulture를 지정해야 한다.
            //
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Thread.CurrentThread.CurrentUICulture.Name);

            if (IsDebugEnabled)
            {
                log.Debug("Current Thread Culture를 지정했습니다. CurrentUICulture=[{0}], CurrrentCulture=[{1}]",
                          Thread.CurrentThread.CurrentUICulture,
                          Thread.CurrentThread.CurrentCulture);
            }

            if (UseUserLocale)
            {
                CookieTool.Set(UserLocaleCookieName, Thread.CurrentThread.CurrentCulture.Name);
            }
        }