This commit is contained in:
Kirthi Krishnamraju 2015-10-23 01:47:29 -07:00
parent 4e8c543489
commit 9658060019
3 changed files with 38 additions and 4 deletions

View File

@ -3,6 +3,7 @@
using System; using System;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Localization;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -38,7 +39,7 @@ namespace MvcSample.Web
app.UseStatusCodePages(); app.UseStatusCodePages();
app.UseFileServer(); app.UseFileServer();
app.UseRequestLocalization(); app.UseRequestLocalization(new RequestCulture("en-US"));
app.UseSession(); app.UseSession();
app.UseMvc(routes => app.UseMvc(routes =>

View File

@ -1,7 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Globalization;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Localization;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace LocalizationWebSite namespace LocalizationWebSite
@ -20,7 +23,20 @@ namespace LocalizationWebSite
{ {
app.UseCultureReplacer(); app.UseCultureReplacer();
app.UseRequestLocalization(); var options = new RequestLocalizationOptions
{
SupportedCultures = new List<CultureInfo>
{
new CultureInfo("fr"),
new CultureInfo("en-GB")
},
SupportedUICultures = new List<CultureInfo>
{
new CultureInfo("fr"),
new CultureInfo("en-GB")
}
};
app.UseRequestLocalization(options, new RequestCulture("en-US"));
app.UseMvcWithDefaultRoute(); app.UseMvcWithDefaultRoute();
} }

View File

@ -1,8 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Localization;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -36,8 +38,23 @@ namespace RazorWebSite
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{ {
app.UseRequestLocalization(); var options = new RequestLocalizationOptions
{
SupportedCultures = new List<CultureInfo>
{
new CultureInfo("fr"),
new CultureInfo("en-GB"),
new CultureInfo("en-US")
},
SupportedUICultures = new List<CultureInfo>
{
new CultureInfo("fr"),
new CultureInfo("en-GB"),
new CultureInfo("en-US")
}
};
app.UseRequestLocalization(options, new RequestCulture("en-GB", "en-US"));
app.UseMvcWithDefaultRoute(); app.UseMvcWithDefaultRoute();
} }
} }