asp.net-core-localization

The Language does not change in the ASP.NET Core Web application

落爺英雄遲暮 提交于 2019-12-07 02:39:27
I follow the Globalization and localization and Building simple multilingual ASP.NET Core website tutorials to add a language switch for my application. So, I created a partial view @using Microsoft.AspNetCore.Builder @using Microsoft.AspNetCore.Http.Features @using Microsoft.AspNetCore.Localization @using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.Extensions.Options @inject IViewLocalizer Localizer @inject IOptions<RequestLocalizationOptions> LocOptions @{ var requestCulture = Context.Features.Get<IRequestCultureFeature>(); var cultureItems = LocOptions.Value.SupportedUICultures

Cannot set default and only culture in ASP.Net Core app

你说的曾经没有我的故事 提交于 2019-12-04 04:06:30
问题 I'm working on Polish operating system: In my Statup.cs class I have following code // Configure the localization options var supportedCultures = new[] { new CultureInfo("en-GB") }; app.UseRequestLocalization( new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("en-GB"), SupportedCultures = supportedCultures, SupportedUICultures = supportedCultures, FallBackToParentCultures = true, FallBackToParentUICultures = true, RequestCultureProviders = null }); The full options

Application unhandled exceptions localization

限于喜欢 提交于 2019-12-02 08:11:01
问题 I am trying to display error messages in locale language and for all handled exceptions my team is using resource file to display in local language but Is there a way to intercept the middleware to display application unhandled exceptions in locale language? 回答1: Standard .NET exceptions are localized and message language will depend on current thread culture. So for you to make it work you'll need to implement RequestCultureMiddleware that would change the language based on your needs. Here

Application unhandled exceptions localization

青春壹個敷衍的年華 提交于 2019-12-02 06:42:05
I am trying to display error messages in locale language and for all handled exceptions my team is using resource file to display in local language but Is there a way to intercept the middleware to display application unhandled exceptions in locale language? Standard .NET exceptions are localized and message language will depend on current thread culture. So for you to make it work you'll need to implement RequestCultureMiddleware that would change the language based on your needs. Here is an example: public class RequestCultureMiddleware { private readonly RequestDelegate next; public

ASP.NET Core DisplayAttribute Localization

旧城冷巷雨未停 提交于 2019-12-01 16:59:30
According to the documentation : The runtime doesn’t look up localized strings for non-validation attributes. In the code above, “Email” (from [Display(Name = "Email")]) will not be localized. I'm looking for a way to localize text in DisplayAttribute. Any suggestions to do it in a proper way(s)? You can set the ResourceType on the DisplayAttribute which can be used to localize your text. Add a resource .resx file to your project e.g. MyResources.resx , and add a resource for your field: Then reference the name of the field and the MyResources type in your DisplayAttribute [Display(Name =

ASP .NET Core 1.0 RTM Localization not working

♀尐吖头ヾ 提交于 2019-11-30 08:36:02
问题 I've been trying to implement localization for my asp .NET Core 1.0 RTM web app following microsofts documentation and I just can not get it to work. The problem I'm having is that it's always displaying strings from the english resource file no matter how I try setting the culture. If anyone has 5 minutes of their time, I'd be really grateful for your input. Here's my Startup.cs content that regards the localization: public void ConfigureServices(IServiceCollection services) { ... services

ASP.NET Core Localization with help of SharedResources

你离开我真会死。 提交于 2019-11-29 22:17:52
Hi I have a question about the SharedResources file. It is glanced over in the tutorial here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization , and I'm not sure if I get it correctly. I am supposed to create a SharedResources.cs class, but where should i put it and should it be empty or do I need to fill it with some data? Same goes for the resource file, should I create a SharedResources.da.resx file and put all my shared strings there? Where should it go? And when I use IHtmlLocalizer<SharedResources> do I just write @using and point it to the namespace where

ASP.NET Core Model Binding Error Messages Localization

主宰稳场 提交于 2019-11-27 11:57:41
I'm using ASP.NET Core, and trying to localize the application. I managed to use new asp .net core resources to localize controllers and views, and old resources to localize error messages for model validation. However, when the error message is not linked to a model field annotation (like "Required") and the data for model binding is incorrect (like a text where a number is expected), I receive the error like below, which I'm unable to localize: "The value 'abc' is not valid for ID." When I enter abc for ID property in View , since the model binding can not be done to the field and it shows a

ASP.NET Core Model Binding Error Messages Localization

大兔子大兔子 提交于 2019-11-26 09:27:54
问题 I\'m using ASP.NET Core, and trying to localize the application. I managed to use new asp .net core resources to localize controllers and views, and old resources to localize error messages for model validation. However, when the error message is not linked to a model field annotation (like \"Required\") and the data for model binding is incorrect (like a text where a number is expected), I receive the error like below, which I\'m unable to localize: \"The value \'abc\' is not valid for ID.\"