From 4b11bdc4be2bd32231e419d33d07531a99e26c00 Mon Sep 17 00:00:00 2001 From: hishamco Date: Mon, 12 Oct 2020 18:15:08 +0300 Subject: [PATCH] Support label localization --- Oqtane.Client/Modules/Controls/Label.razor | 20 ++++++++++++++++++++ Oqtane.Client/Oqtane.Client.csproj | 2 ++ Oqtane.Client/Program.cs | 2 ++ 3 files changed, 24 insertions(+) diff --git a/Oqtane.Client/Modules/Controls/Label.razor b/Oqtane.Client/Modules/Controls/Label.razor index 751b222a..edccb9de 100644 --- a/Oqtane.Client/Modules/Controls/Label.razor +++ b/Oqtane.Client/Modules/Controls/Label.razor @@ -1,5 +1,8 @@ @namespace Oqtane.Modules.Controls @inherits ModuleControlBase +@using Microsoft.AspNetCore.Http +@using Microsoft.Extensions.Localization +@inject IHttpContextAccessor HttpContextAccessor @if (!string.IsNullOrEmpty(HelpText)) { @@ -26,6 +29,9 @@ else [Parameter] public string HelpText { get; set; } // optional - tooltip for this label + [Parameter] + public string ResourceKey { get; set; } + protected override void OnParametersSet() { _openLabel = "@localizer[$"{ResourceKey}.Text"]; + HelpText = localizer[$"{ResourceKey}.{nameof(HelpText)}"]; + } + } } } diff --git a/Oqtane.Client/Oqtane.Client.csproj b/Oqtane.Client/Oqtane.Client.csproj index 515bf8f5..e85799c8 100644 --- a/Oqtane.Client/Oqtane.Client.csproj +++ b/Oqtane.Client/Oqtane.Client.csproj @@ -32,6 +32,8 @@ + + diff --git a/Oqtane.Client/Program.cs b/Oqtane.Client/Program.cs index 912720d9..9b29f544 100644 --- a/Oqtane.Client/Program.cs +++ b/Oqtane.Client/Program.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Oqtane.Modules; using Oqtane.Providers; @@ -26,6 +27,7 @@ namespace Oqtane.Client builder.Services.AddSingleton(httpClient); builder.Services.AddOptions(); + builder.Services.AddSingleton(); // Register localization services builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");