private static string CreateLanguageOption(HtmlHelper helper, GlobalizationManager g, CultureInfo lang)
        {
            switch (g.Settings.CultureStore)
            {
            case GlobalizationSettings.CultureLocation.None:
                return(string.Empty);

            case GlobalizationSettings.CultureLocation.Cookie:
                return(string.Empty);

            case GlobalizationSettings.CultureLocation.Session:
                return(string.Empty);

            case GlobalizationSettings.CultureLocation.URL:
                return(string.Empty);

            case GlobalizationSettings.CultureLocation.QueryString:
                return(string.Empty);

            case GlobalizationSettings.CultureLocation.Subdomain:
                var u = new UrlHelper(helper.ViewContext.RequestContext);
                return(string.Format("<a href=\"{0}\">{1}</a>", u.ChangeCultureLink(lang), lang.DisplayName));
            }
            return(string.Empty);
        }
        private static string CreateLanguageOption(HtmlHelper helper, GlobalizationManager g, CultureInfo lang)
        {
            switch (g.Settings.CultureStore)
            {

                case GlobalizationSettings.CultureLocation.None:
                    return string.Empty;
                case GlobalizationSettings.CultureLocation.Cookie:
                    return string.Empty;
                case GlobalizationSettings.CultureLocation.Session:
                    return string.Empty;
                case GlobalizationSettings.CultureLocation.URL:
                    return string.Empty;
                case GlobalizationSettings.CultureLocation.QueryString:
                    return string.Empty;
                case GlobalizationSettings.CultureLocation.Subdomain:
                    var u = new UrlHelper(helper.ViewContext.RequestContext);
                    return string.Format("<a href=\"{0}\">{1}</a>", u.ChangeCultureLink(lang), lang.DisplayName);
            }
            return string.Empty;
        }
        public static MvcHtmlString LanguageSelector(this HtmlHelper helper)
        {
            var g  = new GlobalizationManager();
            var sb = new StringBuilder();

            if (g.Settings.SupportedLanguages.Count > 1)
            {
                var cc = g.GetCurrentCulture();
                foreach (var l in g.Settings.SupportedLanguages)
                {
                    if (!l.Equals(cc))
                    {
                        sb.Append("<li>{0}</li>".FormatWith(CreateLanguageOption(helper, g, l)));
                    }
                }

                var ul = new TagBuilder("ul");
                ul.GenerateId("language-selector");
                ul.InnerHtml = sb.ToString();
                return(MvcHtmlString.Create(ul.ToString()));
            }
            return(MvcHtmlString.Empty);
        }
        public static MvcHtmlString LanguageSelector(this HtmlHelper helper)
        {
            var g = new GlobalizationManager();
            var sb = new StringBuilder();

            if (g.Settings.SupportedLanguages.Count > 1)
            {
                var cc = g.GetCurrentCulture();
                foreach (var l in g.Settings.SupportedLanguages)
                {
                    if (!l.Equals(cc))
                    {
                        sb.Append("<li>{0}</li>".FormatWith(CreateLanguageOption(helper, g, l)));
                    }
                }

                var ul = new TagBuilder("ul");
                ul.GenerateId("language-selector");
                ul.InnerHtml = sb.ToString();
                return MvcHtmlString.Create(ul.ToString());
            }
            return MvcHtmlString.Empty;
        }
 public SetCultureFilter(GlobalizationManager globalizationManager)
 {
     this.GlobalizationManager = globalizationManager ?? new GlobalizationManager();
 }
Пример #6
0
 public SetCultureFilter(GlobalizationManager globalizationManager)
 {
     this.GlobalizationManager = globalizationManager ?? new GlobalizationManager();
 }