Skip to content

Commit

Permalink
Merge pull request #7 from dotnet-campus/t/ljj/fix-get-value-from-fal…
Browse files Browse the repository at this point in the history
…lback
  • Loading branch information
walterlv authored Oct 30, 2024
2 parents 69e0c0f + 9b65505 commit 40f68a9
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ public class LocalizationValues(ILocalizedValues? fallback) : ILocalizedValues
public string IetfLanguageTag => "default";

/// <inheritdoc />
public string this[string key] => _strings[key] ?? fallback![key];
public string this[string key]
{
get
{
if (_strings.TryGetValue(key,out var value) && value != null)
{
return value;
}
if (fallback != null)
{
return fallback[key];
}
return "";
}
}

private readonly FrozenDictionary<string, string> _strings = new Dictionary<string, string>
{
Expand Down

0 comments on commit 40f68a9

Please sign in to comment.