Exemplo n.º 1
0
        public ActionResult ChangeLanguage(string lang)
        {
            var currentLang = UserCookieManager.GetCurrentLanguageOrDefault();

            if (Request != null)
            {
                if (Request.UrlReferrer != null)
                {
                    var currentUrl = Request.UrlReferrer.ToString();
                    if (!string.IsNullOrEmpty(Request.UrlReferrer.ToString()))
                    {
                        if (currentLang != lang)
                        {
                            new LanguageMessageHandler().SetLanguage(lang);
                        }

                        //HttpResponse.RemoveOutputCacheItem(Request.UrlReferrer.AbsolutePath);
                        //HttpResponse.RemoveOutputCacheItem("/home/index");
                        //HttpResponse.RemoveOutputCacheItem("/");

                        return(Redirect(currentUrl));
                    }
                }
            }

            new LanguageMessageHandler().SetLanguage(lang);

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public static List <IdentityMenu> GetCurrentListMenuByLang(List <IdentityMenu> allMenus)
        {
            try
            {
                var currentLangCode = UserCookieManager.GetCurrentLanguageOrDefault();
                if (allMenus.HasData())
                {
                    foreach (var item in allMenus)
                    {
                        var langItem = item.LangList.Where(x => x.MenuId == item.Id && x.LangCode == currentLangCode).FirstOrDefault();
                        if (langItem != null)
                        {
                            item.CurrentTitleLang = langItem.Title;
                        }
                        else
                        {
                            item.CurrentTitleLang = item.Title;
                        }

                        if (item.SubMenu != null && item.SubMenu.Count() > 0)
                        {
                            item.SubMenu = GetCurrentListMenuByLang(item.SubMenu);
                        }
                    }
                }
            }
            catch
            {
            }

            return(allMenus);
        }
Exemplo n.º 3
0
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
            var lang        = UserCookieManager.GetCurrentLanguageOrDefault();
            var cultureInfo = new CultureInfo(lang);

            Thread.CurrentThread.CurrentUICulture = cultureInfo;
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cultureInfo.Name);

            return(base.BeginExecuteCore(callback, state));
        }
Exemplo n.º 4
0
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
            var lang        = UserCookieManager.GetCurrentLanguageOrDefault();
            var cultureInfo = new CultureInfo(lang);

            Thread.CurrentThread.CurrentUICulture = cultureInfo;
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(cultureInfo.Name);

            if (!User.Identity.IsAuthenticated && !Request.IsAjaxRequest())
            {
                Response.Redirect("~/Account/Login");
            }

            return(base.BeginExecuteCore(callback, state));
        }
Exemplo n.º 5
0
        public static string GetGoogleMapLanguage()
        {
            var paramsFormat = "&language={0}&region={1}";

            try
            {
                var currentLanguage = UserCookieManager.GetCurrentLanguageOrDefault();
                var arr             = currentLanguage.Split('-');
                if (arr.Length > 0)
                {
                    paramsFormat = string.Format(paramsFormat, arr[0], arr[1]);
                }
            }
            catch
            {
                paramsFormat = "&language=en&region=US";
            }

            return(paramsFormat);
        }