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
Question: Can I add localization of Razor components to a Blazor project without using MVC? #12277
Comments
Have you tried using |
@rynowak Thanks for the information. That's what I was searching for. Works as expected. |
Just another thing. Do you have an example on how I can localize e.g. a |
That will just generally work by default since .NET's formatting uses We're making some changes in preview 8 that will make this work correctly with |
@rynowak I am testing a similar approach for localizing a blazor component. Here is my repo: The LocalizedComponent uses IStringLocalizer. A Changing the culture to |
Question
Not actually a bug, but a question. The new Blazor project template uses
EndpointRouting
by default. Can I add localization of Razor components to this without using MVC? If not, how can I configure the project to work with MVC correctly? Or do I just have a problem with understanding something here?I'm trying to follow https://docs.microsoft.com/en-US/aspnet/core/fundamentals/localization?view=aspnetcore-3.0 to add localization support to some razor component.
My
Startup.cs
class (and the component code and_Host.cshtml
) can be found here: https://gist.github.com/SeppPenner/4e3d909a16a53cfab8e701d293344356If I add the commented code:
and
I get the a null reference exception in the
_Host.cshtml
in the lineIf I comment the both lines, it cannot work, of course and it throws the exception:
To Reproduce
Steps to reproduce the behavior:
Startup.cs
and_Host.cshtml
file as described and create the component.Resource files
The resource files are named
TestComponent.en.resx
andTestComponent.de.resx
and located under theTranslations
folder in the mainThe text was updated successfully, but these errors were encountered: