From b59ad6e5ab5bd5cda0d2f2207126870f211ca05b Mon Sep 17 00:00:00 2001 From: Arne Moerman Date: Tue, 19 May 2026 23:30:30 +0200 Subject: [PATCH] Add localization support and UI enhancements Introduced centralized RESX localization with hierarchical keys for multi-language support. Added resource files for English, French, Dutch (Belgium), and pseudo-localization. Replaced hardcoded strings in Razor components with localized string references. Added a `PreferredCulture` property to `ApplicationUser` with a migration to store user-specific culture preferences. Implemented `LocalizationService` to manage supported cultures and user preferences. Added a language picker in `TopBar.razor` and configured `RequestLocalizationOptions` for culture detection. Localized registry-related components and error messages. Enhanced UI elements to dynamically display localized content. Added pseudo-localization to identify hardcoded strings during development. --- .github/copilot-instructions.md | 5 +- .../Components/Layout/MainLayout.razor | 4 +- .../Components/Layout/NavMenu.razor | 12 +- .../Components/Layout/TopBar.razor | 56 +- .../Components/Pages/Error.razor | 19 +- src/BirthList.Web/Components/Pages/Home.razor | 52 +- .../Components/Pages/RegistryActionLog.razor | 38 +- .../Components/Pages/RegistryAdmin.razor | 170 ++--- .../Pages/RegistryContributionAmount.razor | 22 +- .../Components/Pages/RegistryInvite.razor | 12 +- .../Components/Pages/RegistryPublic.razor | 161 ++--- src/BirthList.Web/Components/_Imports.razor | 3 + src/BirthList.Web/Data/ApplicationUser.cs | 4 + ...ferredCultureToApplicationUser.Designer.cs | 292 ++++++++ ...00_AddPreferredCultureToApplicationUser.cs | 29 + .../ApplicationDbContextModelSnapshot.cs | 4 + .../Localization/LocalizationService.cs | 56 ++ src/BirthList.Web/Program.cs | 72 ++ .../Resources/SharedResources.fr-FR.resx | 239 +++++++ .../Resources/SharedResources.nl-BE.resx | 239 +++++++ .../Resources/SharedResources.qps-Ploc.resx | 675 ++++++++++++++++++ .../Resources/SharedResources.resx | 247 +++++++ src/BirthList.Web/SharedResources.cs | 5 + 23 files changed, 2155 insertions(+), 261 deletions(-) create mode 100644 src/BirthList.Web/Data/Migrations/20260519000100_AddPreferredCultureToApplicationUser.Designer.cs create mode 100644 src/BirthList.Web/Data/Migrations/20260519000100_AddPreferredCultureToApplicationUser.cs create mode 100644 src/BirthList.Web/Features/Localization/LocalizationService.cs create mode 100644 src/BirthList.Web/Resources/SharedResources.fr-FR.resx create mode 100644 src/BirthList.Web/Resources/SharedResources.nl-BE.resx create mode 100644 src/BirthList.Web/Resources/SharedResources.qps-Ploc.resx create mode 100644 src/BirthList.Web/Resources/SharedResources.resx create mode 100644 src/BirthList.Web/SharedResources.cs diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 9441863..bfdf8a3 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -6,11 +6,12 @@ - Authentication must support local accounts plus Microsoft and Google login; admin invite links are single-use and not email-locked. - Money participation defaults to EUR and tracks fulfilled amount per item via bank-transfer contributions with item-linked messages. - Registry visibility is public-by-link initially, but logged-in users who visited a registry should be able to rediscover it in-app. -- Identities must be hidden from non-admin users for privacy, only admins and the user who purchased/contributed can see that he did so. Other users may see a generic indication that a contrubution/purchase was made but never a name/email of another user. +- Identities must be hidden from non-admin users for privacy; only admins and the user who purchased/contributed can see that he did so. Other users may see a generic indication that a contribution/purchase was made but never a name/email of another user. - Use SQL Server as the default provider and set `RequireConfirmedAccount=false` for MVP testing; the first registered account should be the owner with full access. ## Technical Specifications - Use SMTP via Google initially for email functionalities. - Support registry type theming from day one to enhance user experience. - URL autofetch should utilize OpenGraph/meta tags for better link previews. -- Use Blazored.TextEditor for rich text editing. \ No newline at end of file +- Use Blazored.TextEditor for rich text editing. +- Use centralized RESX localization with hierarchical keys (not sentence keys); prefer a shared resource file over per-component files, and use pseudo-localization (qps-Ploc) to catch hardcoded strings. \ No newline at end of file diff --git a/src/BirthList.Web/Components/Layout/MainLayout.razor b/src/BirthList.Web/Components/Layout/MainLayout.razor index d20db5a..126492b 100644 --- a/src/BirthList.Web/Components/Layout/MainLayout.razor +++ b/src/BirthList.Web/Components/Layout/MainLayout.razor @@ -9,7 +9,7 @@
- An unhandled error has occurred. - Reload + @L["MainLayout.UnhandledError"] + @L["MainLayout.Reload"] 🗙
diff --git a/src/BirthList.Web/Components/Layout/NavMenu.razor b/src/BirthList.Web/Components/Layout/NavMenu.razor index e7b9934..547d484 100644 --- a/src/BirthList.Web/Components/Layout/NavMenu.razor +++ b/src/BirthList.Web/Components/Layout/NavMenu.razor @@ -4,17 +4,17 @@ - + @@ -38,12 +38,12 @@ diff --git a/src/BirthList.Web/Components/Layout/TopBar.razor b/src/BirthList.Web/Components/Layout/TopBar.razor index 9e991b6..6af0ee4 100644 --- a/src/BirthList.Web/Components/Layout/TopBar.razor +++ b/src/BirthList.Web/Components/Layout/TopBar.razor @@ -1,3 +1,5 @@ +@using System.Globalization +@using BirthList.Web.Features.Localization @using BirthList.Web.Features.Registries @using BirthList.Web.Services @implements IDisposable @@ -10,39 +12,51 @@ @if (ShowProfileCompletionPrompt) {
- Please complete your profile (first name, last name, and address). - Complete profile + @L["TopBar.ProfilePrompt"] + @L["TopBar.CompleteProfile"]
}