From 4b11bdc4be2bd32231e419d33d07531a99e26c00 Mon Sep 17 00:00:00 2001 From: hishamco Date: Mon, 12 Oct 2020 18:15:08 +0300 Subject: [PATCH 1/2] 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 751b222a4..edccb9ded 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 515bf8f55..e85799c8d 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 912720d98..9b29f5448 100644 --- a/Oqtane.Client/Program.cs +++ b/Oqtane.Client/Program.cs @@ -8,6 +8,7 @@ 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 @@ public static async Task Main(string[] args) builder.Services.AddSingleton(httpClient); builder.Services.AddOptions(); + builder.Services.AddSingleton(); // Register localization services builder.Services.AddLocalization(options => options.ResourcesPath = "Resources"); From edc65e66c9b4449ad003b61ccc0ad6b366970b5b Mon Sep 17 00:00:00 2001 From: hishamco Date: Mon, 12 Oct 2020 18:26:04 +0300 Subject: [PATCH 2/2] Use AddHttpContextAccessor() --- Oqtane.Client/Oqtane.Client.csproj | 1 - Oqtane.Client/Program.cs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Oqtane.Client/Oqtane.Client.csproj b/Oqtane.Client/Oqtane.Client.csproj index e85799c8d..eaff964ab 100644 --- a/Oqtane.Client/Oqtane.Client.csproj +++ b/Oqtane.Client/Oqtane.Client.csproj @@ -33,7 +33,6 @@ - diff --git a/Oqtane.Client/Program.cs b/Oqtane.Client/Program.cs index 9b29f5448..7d3ea0a77 100644 --- a/Oqtane.Client/Program.cs +++ b/Oqtane.Client/Program.cs @@ -8,7 +8,6 @@ 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; @@ -27,7 +26,7 @@ public static async Task Main(string[] args) builder.Services.AddSingleton(httpClient); builder.Services.AddOptions(); - builder.Services.AddSingleton(); + builder.Services.AddHttpContextAccessor(); // Register localization services builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");