From 6058f9af2bc5f45ff189471b9fc4d9ae87d71357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20G=C3=B6pel?= Date: Tue, 21 Jul 2026 16:27:11 +0800 Subject: [PATCH] feat: translate sample app to EN/DE (#105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Final step of #105 — translates AndreGoepel.AppFoundation.Sample itself: App.razor's html lang attribute and Home.razor (heading, body copy, three button labels). Follows the marten-identity sample's reference pattern rather than LocalizedComponentBase: the sample is a host app, not a library that needs to render without localization registered, so Home.razor injects IStringLocalizer directly. New Resources/Strings.cs marker type + Strings.resx/Strings.de.resx, kept separate from the RCL's AppFoundationStrings — the host translates its own content independently of the identity/foundation UI it consumes. No behavior change: every English default value is byte-identical to the hardcoded string it replaces, so AppPagesTests.cs's document-title assertion ("AppFoundation Sample", sourced from AppFoundationLayoutOptions. BrandName, not Home.PageTitle) keeps passing unchanged. Verification: - dotnet build -c Release: 0 errors - dotnet csharpier check .: clean, 91 files - Unit tests: 33/33 (MailService) + 68/68 (AppFoundation, unchanged — the sample has no dedicated unit/bUnit coverage, only E2E) - E2E (Playwright + Aspire, full suite): 26/26 This completes the app-foundation#105 translation series. --- .../Components/App.razor | 3 +- .../Components/Pages/Home.razor | 14 ++-- .../Components/_Imports.razor | 2 + .../Resources/Strings.cs | 9 +++ .../Resources/Strings.de.resx | 73 ++++++++++++++++++ .../Resources/Strings.resx | 74 +++++++++++++++++++ 6 files changed, 167 insertions(+), 8 deletions(-) create mode 100644 samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.cs create mode 100644 samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.de.resx create mode 100644 samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.resx diff --git a/samples/AndreGoepel.AppFoundation.Sample/Components/App.razor b/samples/AndreGoepel.AppFoundation.Sample/Components/App.razor index e5d9fbb..7ca5990 100644 --- a/samples/AndreGoepel.AppFoundation.Sample/Components/App.razor +++ b/samples/AndreGoepel.AppFoundation.Sample/Components/App.razor @@ -1,5 +1,6 @@ +@using System.Globalization - + diff --git a/samples/AndreGoepel.AppFoundation.Sample/Components/Pages/Home.razor b/samples/AndreGoepel.AppFoundation.Sample/Components/Pages/Home.razor index 4f61fae..398c6f9 100644 --- a/samples/AndreGoepel.AppFoundation.Sample/Components/Pages/Home.razor +++ b/samples/AndreGoepel.AppFoundation.Sample/Components/Pages/Home.razor @@ -6,32 +6,32 @@ @inject IQuerySession QuerySession @inject NavigationManager NavigationManager +@inject IStringLocalizer L - +
- AppFoundation Sample + @L["Home.Heading"] - A minimal host that wires the AppFoundation packages. Use it to exercise the setup, - sign-in, and administration flows against a real PostgreSQL started by .NET Aspire. + @L["Home.Description"] @if (setupComplete) { - - } else { - } diff --git a/samples/AndreGoepel.AppFoundation.Sample/Components/_Imports.razor b/samples/AndreGoepel.AppFoundation.Sample/Components/_Imports.razor index 6f3ef60..4d0fabe 100644 --- a/samples/AndreGoepel.AppFoundation.Sample/Components/_Imports.razor +++ b/samples/AndreGoepel.AppFoundation.Sample/Components/_Imports.razor @@ -6,6 +6,7 @@ @using static Microsoft.AspNetCore.Components.Web.RenderMode @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop +@using Microsoft.Extensions.Localization @using AndreGoepel.AppFoundation @using AndreGoepel.AppFoundation.Components.Layout @using AndreGoepel.AppFoundation.Components.Shared @@ -14,5 +15,6 @@ @using AndreGoepel.Marten.Identity.Blazor.Components.Account.Shared @using AndreGoepel.AppFoundation.Sample @using AndreGoepel.AppFoundation.Sample.Components +@using AndreGoepel.AppFoundation.Sample.Resources @using Radzen @using Radzen.Blazor diff --git a/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.cs b/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.cs new file mode 100644 index 0000000..41847dd --- /dev/null +++ b/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.cs @@ -0,0 +1,9 @@ +namespace AndreGoepel.AppFoundation.Sample.Resources; + +/// +/// Marker type for the sample app's own UI strings — the generic argument of +/// IStringLocalizer<Strings>. Kept separate from the RCL's +/// AppFoundationStrings: the host translates its own content independently of +/// the identity/foundation UI it consumes. +/// +public sealed class Strings; diff --git a/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.de.resx b/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.de.resx new file mode 100644 index 0000000..f84efd2 --- /dev/null +++ b/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.de.resx @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + + + + + diff --git a/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.resx b/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.resx new file mode 100644 index 0000000..0c11d56 --- /dev/null +++ b/samples/AndreGoepel.AppFoundation.Sample/Resources/Strings.resx @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + + + + +