Check needed if the component is localizable
This commit is contained in:
		| @ -43,7 +43,10 @@ else | ||||
|  | ||||
|         _openLabel += ">"; | ||||
|  | ||||
|         ChildContent =@<text>@Localize("Text")</text>; | ||||
|         HelpText = Localize(nameof(HelpText)); | ||||
|         if (IsLocalizable) | ||||
|         { | ||||
|             ChildContent =@<text>@Localize("Text")</text>; | ||||
|             HelpText = Localize(nameof(HelpText)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -12,10 +12,17 @@ namespace Oqtane.Modules.Controls | ||||
|         [Parameter] | ||||
|         public string ResourceKey { get; set; } | ||||
|  | ||||
|         protected bool IsLocalizable { get; private set; } | ||||
|  | ||||
|         protected string Localize(string name) | ||||
|         { | ||||
|             var key = $"{ResourceKey}.{name}"; | ||||
|             if (!IsLocalizable) | ||||
|             { | ||||
|                 return null; | ||||
|             } | ||||
|  | ||||
|             var key = $"{ResourceKey}.{name}"; | ||||
|   | ||||
|             return _localizer?[key] ?? key; | ||||
|         } | ||||
|  | ||||
| @ -35,6 +42,12 @@ namespace Oqtane.Modules.Controls | ||||
|                         _localizer = (IStringLocalizer)scope.ServiceProvider.GetService(localizerType); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 IsLocalizable = true; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 IsLocalizable = false; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 hishamco
					hishamco