Code Monkey home page Code Monkey logo

scarletkuro / blazor.webassembly.dynamicculture Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 793 KB

Blazor.WebAssembly.DynamicCulture.Loader is a powerful tool that simplifies the process of loading multiple localization satellite assemblies simultaneously during startup in Blazor WebAssembly applications. With this tool, there's no need to manually refresh the page in order to access the new resource assembly.

License: MIT License

C# 98.86% HTML 0.08% JavaScript 1.05%
blazor culture loader localization localize resource resx globalization

blazor.webassembly.dynamicculture's People

Contributors

scarletkuro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blazor.webassembly.dynamicculture's Issues

A question about this project

I have 4 language resources:
new CultureInfo("en")
new CultureInfo("pt")
new CultureInfo("de")
new CultureInfo("cs")
I use the following cultures:
new CultureInfo("en-US"),
new CultureInfo("en-ZA"),
new CultureInfo("en-CA"),
new CultureInfo("en-NZ"),
new CultureInfo("pt-BR"),
new CultureInfo("pt-PT"),
new CultureInfo("de-DE"),
new CultureInfo("de-CH"),
new CultureInfo("de-AT"),
new CultureInfo("cs-CZ"),
Do I now have to specify all cultures in LoadSatelliteCultureAssembliesCultureAsync or is it sufficient that the languages are set?

Dynamic Loader missing culture from browser

Hello

Thanks for developing this great resouce!

I'm having some trouble with the loader. It seems to load all the satellite assemblies except for the one that is set by the browser.

I load the cultures from my resources (yes, confirmed they are all there)

<PropertyGroup>
  ...
    <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
  </PropertyGroup>
image

Program.cs

await host.LoadSatelliteCultureAssembliesCultureAsync([ new CultureInfo("en"),  new CultureInfo("id"),  new CultureInfo("th"),  new CultureInfo("zh-Hans"), ]);
		await host.RunAsync();

If my default browser language is not one of the list, then switching between cultures and then calling StateHasChanged()

CultureInfo.DefaultThreadCurrentCulture 
			= CultureInfo.DefaultThreadCurrentUICulture
				= CultureInfo.CurrentCulture
					= CultureInfo.CurrentUICulture
						= new CultureInfo("th");
StateHasChanged();

works fine.

But when I set the browser's default language to Thai (say):

image

Then doing this does not work. It only displays the default culture when I call this:

CultureInfo.DefaultThreadCurrentCulture 
			= CultureInfo.DefaultThreadCurrentUICulture
				= CultureInfo.CurrentCulture
					= CultureInfo.CurrentUICulture
						= new CultureInfo("th");
StateHasChanged();

But all the other cultures (except "th") works fine. Conversely if I set my browser default to say, Japanese (which is not on my list of supported cultures), then all the cultures can be rendered.

Do you update this project to .Net7?

I get follow hints by compile it:
3>EntityFrameworkPaginate -> C:\Users\ingo\source\repos\TipBlazor\EntityFrameworkPaginate\bin\Debug\net7.0\EntityFrameworkPaginate.dll
2>C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\WebAssemblyCultureProvider.cs(75,32,79,18): warning CS0618: "IJSUnmarshalledRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string, T0, T1, T2)" ist veraltet: "This method is obsolete. Use JSImportAttribute instead."
2>C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\WebAssemblyCultureProvider.cs(84,26,88,18): warning CS0618: "IJSUnmarshalledRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string, T0, T1, T2)" ist veraltet: "This method is obsolete. Use JSImportAttribute instead."
2>Blazor.WebAssembly.DynamicCulture.Loader -> C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\bin\Debug\net7.0\Blazor.WebAssembly.DynamicCulture.Loader.dll
2>Erstellen des Projekts Blazor.WebAssembly.DynamicCulture.Loader.csproj beendet.
5>------ Neues Erstellen gestartet: Projekt: Blazor.WebAssembly.DynamicCulture, Konfiguration: Debug Any CPU ------
5>C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture\LanguageTrackProvider.cs(18,27,18,36): warning BL0007: Component parameter 'Blazor.WebAssembly.DynamicCulture.LanguageTrackProvider.Component' should be auto property
5>Blazor.WebAssembly.DynamicCulture -> C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture\bin\Debug\net7.0\Blazor.WebAssembly.DynamicCulture.dll

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.