mirror of
https://github.com/oqtane/oqtane.framework.git
synced 2025-05-17 10:09:24 +00:00
Merge pull request #1490 from sbwalker/dev
add extension method for Localization which allows specification of key and value
This commit is contained in:
commit
a953ca752e
22
Oqtane.Client/Extensions/OqtaneLocalizationExtensions.cs
Normal file
22
Oqtane.Client/Extensions/OqtaneLocalizationExtensions.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
namespace Microsoft.Extensions.Localization
|
||||||
|
{
|
||||||
|
public static class OqtaneLocalizationExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the string resource for the specified key and returns the value if the resource does not exist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localizer"></param>
|
||||||
|
/// <param name="key">the static key used to identify the string resource</param>
|
||||||
|
/// <param name="value">the default value if the resource for the static key does not exist</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetString(this IStringLocalizer localizer, string key, string value)
|
||||||
|
{
|
||||||
|
string localizedValue = localizer[key];
|
||||||
|
if (localizedValue == key) // not localized
|
||||||
|
{
|
||||||
|
localizedValue = value;
|
||||||
|
}
|
||||||
|
return localizedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user