Label should use LocalizableComponent
This commit is contained in:
		| @ -1,6 +1,5 @@ | ||||
| @namespace Oqtane.Modules.Controls | ||||
| @inherits ModuleControlBase | ||||
| @using Microsoft.Extensions.Localization | ||||
| @namespace Oqtane.Modules.Controls | ||||
| @inherits LocalizableComponent | ||||
|  | ||||
| @if (!string.IsNullOrEmpty(HelpText)) | ||||
| { | ||||
| @ -27,11 +26,10 @@ else | ||||
|     [Parameter] | ||||
|     public string HelpText { get; set; } // optional - tooltip for this label | ||||
|  | ||||
|     [Parameter] | ||||
|     public string ResourceKey { get; set; } | ||||
|  | ||||
|     protected override void OnParametersSet() | ||||
|     { | ||||
|         base.OnParametersSet(); | ||||
|  | ||||
|         _openLabel = "<label"; | ||||
|         if (!string.IsNullOrEmpty(For)) | ||||
|         { | ||||
| @ -47,21 +45,8 @@ else | ||||
|  | ||||
|         if (!string.IsNullOrEmpty(ResourceKey)) | ||||
|         { | ||||
|             if (ModuleState?.ModuleType != null) | ||||
|             { | ||||
|                 var moduleType = Type.GetType(ModuleState.ModuleType); | ||||
|                 var localizerTypeName = $"Microsoft.Extensions.Localization.IStringLocalizer`1[[{moduleType.AssemblyQualifiedName}]], Microsoft.Extensions.Localization.Abstractions"; | ||||
|                 var localizerType = Type.GetType(localizerTypeName); | ||||
|  | ||||
|                 // HACK: Use ServiceActivator instead of injecting IHttpContextAccessor, because HttpContext throws NRE in WebAssembly runtime | ||||
|                 using (var scope = ServiceActivator.GetScope()) | ||||
|                 { | ||||
|                     var localizer = (IStringLocalizer)scope.ServiceProvider.GetService(localizerType); | ||||
|  | ||||
|                     ChildContent = @<text>@localizer[$"{ResourceKey}.Text"]</text>; | ||||
|                     HelpText = localizer[$"{ResourceKey}.{nameof(HelpText)}"]; | ||||
|                 } | ||||
|             } | ||||
|             ChildContent =@<text>@Localizer[$"{ResourceKey}.Text"]</text>; | ||||
|             HelpText = Localizer[$"{ResourceKey}.{nameof(HelpText)}"]; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 hishamco
					hishamco