-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Blazor Server Side Localization not working #12088
Comments
Thanks for contacting us, @aherrick. |
@mkArtakMSFT do you have an example of this within the context of Blazor or the example I posted? |
@aherrick not really. I'll leave this as a question for community members to help you out with. |
OK - it would be nice if there was some documentation or examples on how to do Localization with Blazor. |
I whipped together something very crude last week as I ran into the same problem and I needed a quick fix for it. I ended up with something along the lines of the following. Maybe it can send you on the right track for your needs. See this gist: https://gist.github.com/christiansparre/5576907ad391b972581714f7564674b7
|
@christiansparre Awesome! Are you initializing TextService as a singleton? |
Yes @aherrick it's registered as singleton |
What about @page "/"
@using Microsoft.Extensions.Localization;
@inject IStringLocalizer<Index> L
<h1>Hello, world!</h1>
Welcome to your new app.
<h1>@L["Hello"]</h1>
@code {
} Don't forget to add services.AddLocalization(options => options.ResourcesPath = "Translations"); to your
|
I'd like to expand on @SeppPenner post, as I found the following to work based on the browser's preferred language. Startup.cs
Pages/Index.razor
Resource files /Resources |
Localization is critical for us. I really hope MS comes up with official guidance on this soon. I also hope that the mechanism will be server/client side agnostic as well as not impact unit testing. |
@GiroSA I don't know where the problem is here exactly, but it works perfectly for server side in my projects... |
@GiroSA did you try my example? |
I cannot get the StringLocalizer to work on a Blazor Client Side Application. The Resource Files are published to the Output Folder but the Loalizer allways reports no Manifest found for the current Culture, which do exist. |
@endeffects As far as I know, there is a seperate issue for that. |
@aaronhudon-ts Can you share a repo that demonstrates your approach in #12088 (comment)? I am still not able to make it work. |
@Stamo-Gochev Are your resource files in the same project, under the folder "Resources"? This also assumes Server-Side Blazor. |
@aaronhudon-ts They are, the problem seems to be that localization of blazor components is not currently supported #16687 (comment) |
@Stamo-Gochev I am only using |
I am finally back on this after a huge detour. I have implemented and am using a custom IStringLocalizer and it works as expected server side. I am not going to worry about client side for now. I am hoping that MS would have kept the infrastructure the same for both client and server side by the time they shipped the client side in May next year. |
Thank you for contacting us. Due to no activity on this issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue. |
Trying to stand up a super simple example of Blazor Server Side with Localization/Translation support.
I posted the spike here: https://github.com/aherrick/BlazorServerSideLocalization
It appears in my
Index.razor
view@inject IViewLocalizer L
is always null. I have aResources
folder with aPages.Index.en.resx
The text was updated successfully, but these errors were encountered: