Example #1
0
        private static void SetCultureInfo(SignInContext context, string language)
        {
            context.SignInInfo.Properties["Culture"] = language;

            IUserCultureInfoAccessor accessor = UserCultureInfoSettings.GetConfig().UserCultureInfoAccessor;

            if (accessor != null)
            {
                accessor.SaveUserLanguageID(HttpContext.Current.User.Identity.Name, language);
            }
        }
Example #2
0
        private static CultureInfo GetCultureInfo()
        {
            string language = TranslatorConfigSettings.GetConfig().DefaultCulture.Name;

            HttpRequest request = HttpContext.Current.Request;

            if (GlobalizationWebHelper.TryGetLanguageFromQueryString(ref language) == false)
            {
                if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    try
                    {
                        if (TryGetLanguageFromTicket(ref language) == false)
                        {
                            IUserCultureInfoAccessor accessor = UserCultureInfoSettings.GetConfig().UserCultureInfoAccessor;

                            if (accessor != null)
                            {
                                language = accessor.GetCurrentUserLanguageID(HttpContext.Current.User.Identity.Name, language);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        WriteExceptionToLog(ex);
                    }
                }
            }

            CultureInfo translatedCulture = null;

            int cultureID = 2052;

            if (int.TryParse(language, out cultureID))
            {
                translatedCulture = new CultureInfo(cultureID);
            }
            else
            {
                translatedCulture = new CultureInfo(language);
            }

            translatedCulture.DateTimeFormat.DateSeparator       = "-";
            translatedCulture.DateTimeFormat.FullDateTimePattern = "yyyy-MM-dd HH:mm:ss";
            translatedCulture.DateTimeFormat.LongDatePattern     = "yyyy-MM-dd";
            translatedCulture.DateTimeFormat.LongTimePattern     = "HH:mm:ss";
            translatedCulture.DateTimeFormat.ShortDatePattern    = "yyyy-MM-dd";
            translatedCulture.DateTimeFormat.ShortTimePattern    = "HH:mm";

            return(translatedCulture);
        }