Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How do i get text from IStringLocalizer from file on Blazor?

$
0
0

I'm trying to use Istringlocalizer from c# on an MudBlazor html solution. I've got all Istringlocalizer configuration and it is working all correctly but I can't get the text from a file.

To put it on an example, I've got file.txt, also in the same folder for example file.txt.en-US on my wwwroot folder. A file resources.resx and resources.resx.en-US where i put a new entrance with the key textFromFile.

All right until now but when I put the IStringLocalizer<...> txt["textFromFile"] which is on every page I use initialized through @inject IStringLocalizer<...> txt on the page doesn't work. Why? I know that it isn't just a string but a byte[] but the variable doesn't allow me to type int in another way such as (byte[])txt["textFromFile"]. Is it posible that I'm understanting wrong how it works and the referenced file must have a specified format such as json?

Error log:

warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]      Unhandled exception rendering component: Cannot access a disposed object.      System.ObjectDisposedException: Cannot access a disposed object.         at fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]      Unhandled exception in circuit '6qYQC988G4gwi7cf1MN8Bz6hsfckOq8CghWZccVVZN4'.      System.ObjectDisposedException: Cannot access a disposed object.warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]          Unhandled exception rendering component: Resource was of type 'ByteArray' instead of String - call GetObject instead.    fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]          Unhandled exception in circuit '6qYQC988G4gwi7cf1MN8Bz6hsfckOq8CghWZccVVZN4'.          System.InvalidOperationException: Resource was of type 'ByteArray' instead of String - call GetObject instead.

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>