Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data annotation localization current culture missmatch #2638

Closed
aspnet-hello opened this issue Jan 2, 2018 · 3 comments
Closed

Data annotation localization current culture missmatch #2638

aspnet-hello opened this issue Jan 2, 2018 · 3 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Comments

@aspnet-hello
Copy link

From @stenvix on Monday, May 22, 2017 1:33:54 AM

Technical details

Operating system: Windows 10
IDE: Visual Studio 2017 Professional Version 15.2(26430.6)
Runtime: .NET Core 1.1

Information

I had strange behaviour when use data annotation with "ResourceType",

Like in docs I init localization:
ConfigureServices

            services.AddLocalization(options => options.ResourcesPath = "Resources");

            services.AddMvc()
                .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
                .AddDataAnnotationsLocalization();

Configure

            var supportedCultures = new List<CultureInfo>
            {
                new CultureInfo("en"),
                new CultureInfo("uk"),
                new CultureInfo("ru")
            };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("en"),
                SupportedCultures = supportedCultures,
                SupportedUICultures = supportedCultures
            });

In model I use attribute

[Display(Name = nameof(RememberMe), ResourceType = typeof(DataAnnotations))]

IHtmlLocalizer, IStringLocalizer working correctly, But name on DataAnnotations use Russian resx by default
English Language:
English
Link

But if I use Ukrainian language all working fine

Ukrainian Language:
Ukrainian
Link

Have any logical explanation why this happend??

Copied from original issue: aspnet/Localization#371

@aspnet-hello
Copy link
Author

From @hishamco on Monday, May 22, 2017 3:59:38 AM

@stenvix please refer to this issue #343, if everything as expected, please share a repo that reproduces the issue that you are facing

@aspnet-hello
Copy link
Author

From @rynowak on Monday, May 22, 2017 8:11:23 AM

@stenvix can you share your model code? The data annotations attributes have some complicated behavior because they have their own localization system.

@Eilon Eilon added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed repo:Localization labels Nov 7, 2018
@mkArtakMSFT
Copy link
Member

Hi. We're closing this issue as we have heard no response from you for some time now. If you have more details and are encountering this issue please add a new reply and re-open the issue.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

No branches or pull requests

3 participants