Skip to content

Commit

Permalink
Prevent NREs for null text (#8418)
Browse files Browse the repository at this point in the history
When the text we are localizing is null (which potentially happens when localizing dynamic content), it could result in a null parent translation, which would throw when used as "basis" for comparisons.
  • Loading branch information
MatteoPiovanelli-Laser authored Sep 21, 2020
1 parent 0d3f3ed commit 70c04a9
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public DefaultLocalizedStringManager(

public FormatForScope GetLocalizedString(IEnumerable<string> scopes, string text, string cultureName) {
var culture = LoadCulture(cultureName);
text = text ?? string.Empty; // prevent NREs with this string
foreach (var scope in scopes) {
string scopedKey = (scope + "|" + text).ToLowerInvariant();
if (culture.Translations.ContainsKey(scopedKey)) {
Expand Down

0 comments on commit 70c04a9

Please sign in to comment.