From b2d5b08847fa492b93693a688d12304c4580c8a9 Mon Sep 17 00:00:00 2001 From: Marvin Klein <32510006+MarvinKlein1508@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:53:51 +0200 Subject: [PATCH 1/2] Add table with default translation key value pairs --- .../LocalizationDefaultTranslations.razor | 52 +++++++++++++++++++ .../Documentation/GetStarted/Localization.md | 4 ++ 2 files changed, 56 insertions(+) create mode 100644 examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor diff --git a/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor new file mode 100644 index 0000000000..6e443f3532 --- /dev/null +++ b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor @@ -0,0 +1,52 @@ +@using System.Resources +@using System.Reflection +@using System.Globalization +@using System.Collections + + + + + + + + + + @foreach (var entry in _localizedStrings) + { + + + + + } + +
KeyDefault translation
@entry.Key@entry.Value
+ + + +@code { + + private Dictionary _localizedStrings = []; + + protected override Task OnInitializedAsync() + { + var resourceManager = Microsoft.FluentUI.AspNetCore.Components.Localization.LanguageResource.ResourceManager; + var culture = CultureInfo.InvariantCulture; + ResourceSet? resourceSet = resourceManager.GetResourceSet(culture, true, true); + + if (resourceSet is not null) + { + _localizedStrings = resourceSet + .Cast() + .Where(e => e.Value is string) + .OrderBy(x => x.Key) + .ToDictionary( + e => (string)e.Key, + e => e.Value as string ?? string.Empty + ); + + } + + return base.OnInitializedAsync(); + } + +} diff --git a/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Localization.md b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Localization.md index 652960d771..afe3d8dc87 100644 --- a/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Localization.md +++ b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Localization.md @@ -128,3 +128,7 @@ You can use an embedded resource to store your translations. } } ``` + + ## Default translations + + {{ LocalizationDefaultTranslations SourceCode=false }} From f396715dc16ff1bf8a2738a580795c675645d094 Mon Sep 17 00:00:00 2001 From: Marvin Klein <32510006+MarvinKlein1508@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:55:19 +0200 Subject: [PATCH 2/2] Remove using --- .../GetStarted/Examples/LocalizationDefaultTranslations.razor | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor index 6e443f3532..fe6413dc84 100644 --- a/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor +++ b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor @@ -1,5 +1,4 @@ @using System.Resources -@using System.Reflection @using System.Globalization @using System.Collections