aspnetcore/test/LocalizationWebsite/StartupResourcesAtRootFolde...

40 lines
1.3 KiB
C#

// 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.
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
namespace LocalizationWebsite
{
public class StartupResourcesAtRootFolder
{
public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization();
}
public void Configure(
IApplicationBuilder app,
ILoggerFactory loggerFactory,
IStringLocalizerFactory stringLocalizerFactory,
IStringLocalizer<StartupResourcesAtRootFolder> startupStringLocalizer)
{
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
app.UseRequestLocalization();
var stringLocalizer = stringLocalizerFactory.Create("Test", location: null);
app.Run(async (context) =>
{
await context.Response.WriteAsync(startupStringLocalizer["Hello"]);
await context.Response.WriteAsync(" ");
await context.Response.WriteAsync(stringLocalizer["Hello"]);
});
}
}
}