The first article looked at how to work with cultures, and the second covered the basics of using resource files for static content translations.
This is the third article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. The first article looked at how to work with cultures, and the second covered the basics of using resource files for static content translations. In this article, I explain how to provide localised resources for form labels and validation error messages for PageModel properties that have Data Annotation attributes applied to them.
The application in this article is the same one that has featured in the previous articles. It's built using the standard Razor Pages 3.1 project template with no authentication. Many of the concepts in this article were originally introduced in the previous article, so you should read that first.
The first three steps that follow demonstrate the minimum configuration to enable localisation using resources. If you are continuing from the previous article, you will have covered those:
ConfigureServices
, localization is added to the DI container, specifying the location of resources in the application, and the cultures supported by the application are configured:public void ConfigureServices(IServiceCollection services)
{
services.AddLocalization(options => options.ResourcesPath = "resources");
services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[]
{
new CultureInfo("en"),
new CultureInfo("de"),
new CultureInfo("fr"),
new CultureInfo("es"),
new CultureInfo("ru"),
new CultureInfo("ja"),
new CultureInfo("ar"),
new CultureInfo("zh"),
new CultureInfo("en-GB")
};
options.DefaultRequestCulture = new RequestCulture("en-GB");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});
services.AddSingleton<CommonLocalizationService>();
}
Data science is omnipresent to advanced statistical and machine learning methods. For whatever length of time that there is data to analyse, the need to investigate is obvious.
Tableau Data Analysis Tips and Tricks. Master the one of the most powerful data analytics tool with some handy shortcut and tricks.
Analysis, Price Modeling and Prediction: AirBnB Data for Seattle. A detailed overview of AirBnB’s Seattle data analysis using Data Engineering & Machine Learning techniques.
DISCLAIMER: absolutely subjective point of view, for the official definition check out vocabularies or Wikipedia. And come on, you wouldn’t read an entire article just to get the definition.
Suppose you are looking to book a flight ticket for a trip of yours. Now, you will not go directly to a specific site and book the first ticket that you see.