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..fe6413dc84 --- /dev/null +++ b/examples/Demo/FluentUI.Demo.Client/Documentation/GetStarted/Examples/LocalizationDefaultTranslations.razor @@ -0,0 +1,51 @@ +@using System.Resources +@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 }}