private string GetDefaultCultureCode()
        {
            IStorage storage        = this.serviceProvider.GetService <IStorage>();
            Culture  defaultCulture = CultureManager.GetDefaultCulture(storage);

            if (defaultCulture == null)
            {
                return(DefaultCulture.Code);
            }

            return(defaultCulture.Code);
        }
Beispiel #2
0
        public override Task <ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext)
        {
            string cultureCode = null;

            if (httpContext.Request.Path.HasValue && httpContext.Request.Path.Value.Length >= 4 && httpContext.Request.Path.Value[0] == '/' && httpContext.Request.Path.Value[3] == '/')
            {
                cultureCode = httpContext.Request.Path.Value.Substring(1, 2);
            }

            else
            {
                IStorage storage = this.serviceProvider.GetService <IStorage>();

                if (storage == null)
                {
                    cultureCode = "en";
                }

                else
                {
                    Culture defaultCulture = CultureManager.GetDefaultCulture(storage);

                    if (defaultCulture == null)
                    {
                        cultureCode = "en";
                    }

                    else
                    {
                        cultureCode = defaultCulture.Code;
                    }
                }
            }

            ProviderCultureResult requestCulture = new ProviderCultureResult(cultureCode);

            return(Task.FromResult(requestCulture));
        }