Check needed if the component is localizable
This commit is contained in:
parent
fed56098a0
commit
79b584f268
|
@ -43,7 +43,10 @@ else
|
|||
|
||||
_openLabel += ">";
|
||||
|
||||
if (IsLocalizable)
|
||||
{
|
||||
ChildContent =@<text>@Localize("Text")</text>;
|
||||
HelpText = Localize(nameof(HelpText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,15 @@ namespace Oqtane.Modules.Controls
|
|||
[Parameter]
|
||||
public string ResourceKey { get; set; }
|
||||
|
||||
protected bool IsLocalizable { get; private set; }
|
||||
|
||||
protected string Localize(string 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user