Skip to content

Localization not working in Browser using .NET 8 #15223

Answered by MrJul
andrewkdci asked this question in Q&A
Discussion options

You must be logged in to vote

By default, the .NET WASM runtime doesn't load any satellite (resource) assemblies.
Blazor loads them for the current culture at startup (and doesn't support dynamic culture by default).

I don't believe it's Avalonia role to load them. You'll get the same behavior with a non-Blazor WASM project.

Workaround:

internal partial class WebAssemblyCultureProviderInterop
{
    [JSImport("INTERNAL.loadSatelliteAssemblies")]
    public static partial Task LoadSatelliteAssemblies(string[] culturesToLoad);
}

Before using the culture:

await WebAssemblyCultureProviderInterop.LoadSatelliteAssemblies(["ja-JP"]);

Only tested in .NET 8.0 (it might be different in .NET 7.0).
Source reference:

https://github…

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@andrewkdci
Comment options

@andrewkdci
Comment options

@andrewkdci
Comment options

@MrJul
Comment options

MrJul Apr 5, 2024
Maintainer

Answer selected by andrewkdci
@andrewkdci
Comment options

@andrewkdci
Comment options

@xuxiaokang0723
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #15220 on April 03, 2024 19:06.