Build server | Platforms | Build status |
---|---|---|
Github Actions | windows-latest, ubuntu-latest | Branch: develop |
Github Actions | windows-latest, ubuntu-latest | Branch: master |
Sponsored by Finter Mobility AS. We are hiring! Check out our remote positions over at finterjobs.com.
- ASP.NET Core 3.1
The i18n library is designed to replace the use of .NET resources in favor of an easier, globally recognized standard for localizing ASP.NET-based web applications.
<PackageReference Include="i18n.Core" Version="1.0.10" />
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddI18NLocalization(HostEnvironment, options =>
{
var supportedCultures = new[]
{
new CultureInfo("nb-NO"),
new CultureInfo("en-US")
};
var defaultCulture = supportedCultures.Single(x => x.Name == "en-US");
options.DefaultRequestCulture = new RequestCulture(defaultCulture);
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
options.RequestCultureProviders = new List<IRequestCultureProvider>
{
new CookieRequestCultureProvider()
};
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseI18NRequestLocalization();
}
dotnet tool install pot -g
pot --watch
NB! This is not required for this to work as you can configure this middleware by resolving IOptions<I18NLocalizationOptions>
. It's available for legacy reasons only.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="i18n.DirectoriesToScan" value=".;"/>
<add key="i18n.GenerateTemplatePerFile" value="false"/>
</appSettings>
</configuration>
A demo project is available in this repository. You can find it here
This project is mainly built on hard work of the following projects: