Skip to content

Migrate Blazor WebAssembly localization sample to CodeMazeGuides, retarget net10.0 - #2117

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/56244-localization-in-blazor-webassembly-applications
Open

Migrate Blazor WebAssembly localization sample to CodeMazeGuides, retarget net10.0#2117
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/56244-localization-in-blazor-webassembly-applications

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Migrates the sample for Blazor Localization in WebAssembly Applications out of the standalone CodeMazeBlog/blazor-wasm-localization repository and into this one as blazor-features/BlazorWebAssemblyLocalization, retargeted from net5.0 to net10.0.

What changed against the old sample

Old (blazor-wasm-localization, net5.0) New
<TargetFramework>net5.0</TargetFramework> net10.0
Four 5.0.0-rc.2.20475.* package pins Microsoft.AspNetCore.Components.WebAssembly / .DevServer / Microsoft.Extensions.Localization at 10.0.10; System.Net.Http.Json dropped (shared framework since .NET 5)
class Program { static async Task Main(string[] args) } Top-level statements
Pages/Index.razor Pages/Home.razor
Shared/MainLayout.razor, Shared/NavMenu.razor Layout/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?") Removed — not in the current template
No <Nullable> element <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings>; NavManager and JSRuntime get the = default!; property-injection idiom

The localization itself is unchanged in substance: AddLocalization(), Resource.resx / Resource.de.resx, IStringLocalizer<Resource> in Home.razor, the CultureSelector component, WebAssemblyHostExtension.SetDefaultCulture(), the blazorCulture localStorage bridge in index.html, and <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData> in the project file.

Verification

dotnet build BlazorWebAssemblyLocalization.sln -c Release on SDK 10.0.302: 0 warnings, 0 errors.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant