Skip to content

Extensions

// RB2 Core Connect
namespace CoreConnect.Commerce.Core;
public static class DictionaryExtensions
{
public static string? GetValue(this Dictionary<string, string> localizedString, string? locale)
{
if (locale == null)
{
return null;
}
if (localizedString.TryGetValue(locale, out var value)) {
return value;
}
var n= locale.IndexOf('-');
if (n > 0) {
var locale2 = locale.Substring(0, n);
if (localizedString.TryGetValue(locale2, out var value2)) {
return value2;
}
}
return localizedString.FirstOrDefault().Value;
}
}