Migrate Blazor WebAssembly localization sample to CodeMazeGuides, retarget net10.0 - #2117
Open
vladimir-pecanac-main wants to merge 1 commit into
Conversation
…ization, retarget net10.0 Brings the sample for "Blazor Localization in WebAssembly Applications" into this repo as blazor-features/BlazorWebAssemblyLocalization. It previously lived in the standalone CodeMazeBlog/blazor-wasm-localization repository on net5.0. - Rebuilt on the current Blazor WebAssembly Standalone App template: Layout/ folder for MainLayout and NavMenu, Pages/Home.razor instead of Pages/Index.razor, top-level statements in Program.cs, no SurveyPrompt. - net5.0 -> net10.0; the four 5.0.0-rc.2 package pins replaced by Microsoft.AspNetCore.Components.WebAssembly(.DevServer) and Microsoft.Extensions.Localization at 10.0.10; System.Net.Http.Json dropped (in the shared framework since .NET 5). - Nullable reference types and implicit usings enabled, matching the template and the other samples here; NavManager and JSRuntime use the = default!; property-injection idiom. - MainLayout rewritten against the current template markup (main / article.content); the old div.main wrapper no longer exists. Builds clean: 0 warnings, 0 errors on SDK 10.0.302.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the sample for Blazor Localization in WebAssembly Applications out of the standalone
CodeMazeBlog/blazor-wasm-localizationrepository and into this one asblazor-features/BlazorWebAssemblyLocalization, retargeted fromnet5.0tonet10.0.What changed against the old sample
blazor-wasm-localization,net5.0)<TargetFramework>net5.0</TargetFramework>net10.05.0.0-rc.2.20475.*package pinsMicrosoft.AspNetCore.Components.WebAssembly/.DevServer/Microsoft.Extensions.Localizationat10.0.10;System.Net.Http.Jsondropped (shared framework since .NET 5)class Program { static async Task Main(string[] args) }Pages/Index.razorPages/Home.razorShared/MainLayout.razor,Shared/NavMenu.razorLayout/MainLayout.razor,Layout/NavMenu.razor<div class="main"> <div class="top-row px-4"> … <div class="content px-4"><main> <div class="top-row px-4"> … <article class="content px-4">(current template markup)SurveyPrompt.razor("How is Blazor working for you?")<Nullable>element<Nullable>enable</Nullable>+<ImplicitUsings>enable</ImplicitUsings>;NavManagerandJSRuntimeget the= default!;property-injection idiomThe localization itself is unchanged in substance:
AddLocalization(),Resource.resx/Resource.de.resx,IStringLocalizer<Resource>inHome.razor, theCultureSelectorcomponent,WebAssemblyHostExtension.SetDefaultCulture(), theblazorCulturelocalStoragebridge inindex.html, and<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>in the project file.Verification
dotnet build BlazorWebAssemblyLocalization.sln -c Releaseon SDK 10.0.302: 0 warnings, 0 errors.