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