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

Runtime Culture and Localization #5471

Closed
grahamehorner opened this issue Feb 7, 2018 · 8 comments
Closed

Runtime Culture and Localization #5471

grahamehorner opened this issue Feb 7, 2018 · 8 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Duplicate Resolved as a duplicate of another issue

Comments

@grahamehorner
Copy link
Contributor

Please consider browser runtime cultural and allow switching of culture with in the Blazor environment

@SteveSandersonMS
Copy link
Member

Good idea. It will be a while before we get to it, but it's good to have on the backlog.

@SteveSandersonMS SteveSandersonMS changed the title Blazor Runtime Culture Blazor Runtime Culture and Localisation Feb 9, 2018
@SteveSandersonMS SteveSandersonMS changed the title Blazor Runtime Culture and Localisation Runtime Culture and Localisation Feb 9, 2018
@danroth27 danroth27 changed the title Runtime Culture and Localisation Runtime Culture and Localization Mar 24, 2018
@DNF-SaS
Copy link

DNF-SaS commented Apr 11, 2018

Strange: ResourceManager.GetResourceSet() just returns null for every localized resource (these who reside in files with the ISO639-1 code in the filename)?

@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one area-blazor Includes: Blazor, Razor Components labels Dec 17, 2018
@SteveSandersonMS
Copy link
Member

When doing this, be sure to check cases around Data Annotations validation and the built-in parsing validators in the Input* components to be sure they localize conveniently.

@DamianEdwards
Copy link
Member

Is this issue intended to cover just the WASM side of the world, or localization in the Razor Components server-side features in 3.0 too?

@SteveSandersonMS
Copy link
Member

@DamianEdwards Both. Currently this issue is quite high-level and all-encompassing, but will get broken down into several sub-issues as we start work on it.

@rynowak rynowak mentioned this issue Mar 5, 2019
56 tasks
@rynowak rynowak added the Components Big Rock This issue tracks a big effort which can span multiple issues label Mar 5, 2019
@grahamehorner
Copy link
Contributor Author

grahamehorner commented Mar 5, 2019

IMHO and just for my two pennies worth @SteveSandersonMS ;) as a developer of a multi-lingual application Razor Component circuits would need some mechanism to send the users browser culture to the server; to allow the rendering component(s) to identifier the correct resources to use and/or having routing determine any culture specifics; so for a starter for 10 a smaller task of the bigger story IMHO would be to possibly update the component circuit implementation to provide browser agent string and culture with in the messages sent to the signalr hub.

NOTE: do you think a user should be able to switch culture of the browser without causing issues/re-login etc. ? or should a user session be forced into a fixed culture ?

@Franklin89
Copy link

Franklin89 commented Apr 9, 2019

I have experienced a strange behavior (in my opinion strange) as I wanted to try to implement some sort of localization (client side blazor). If I set the CultureInfo in the startup of the client app:

public void Configure(IComponentsApplicationBuilder app)
{
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("de-CH");
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-CH");
app.AddComponent("app");
}

and then render a input with a DateTime field the input gets rendered in the correct format according to the culture. If I then change the date inside the input and the state gets updated the date gets displayed in the default format. I then tried the same with a string property.

public string Birthdate
{
get
{
Console.WriteLine(System.Threading.Thread.CurrentThread.CurrentCulture);
return Birthdate.ToShortDateString();
}
set
{
Birthdate = DateTime.Parse(value);
}
}

The culture that gets written to the console first shows the correct culture. After changing the value the culture is empty. So it seems to me that the culture gets cleared somehow.

Update
Of course we don't need to change the CurrentThread but the CultureInfo.DefaultThreadCurrentCulture. So after changing it to:

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("de-CH");
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("de-CH");

all is working as expected.

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@rynowak
Copy link
Member

rynowak commented May 29, 2019

We're using #9386 to track this area.

@rynowak rynowak closed this as completed May 29, 2019
@rynowak rynowak removed this from the Backlog milestone May 29, 2019
@rynowak rynowak added ✔️ Resolution: Duplicate Resolved as a duplicate of another issue and removed Components Big Rock This issue tracks a big effort which can span multiple issues labels May 29, 2019
@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-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

8 participants