mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-06-28 15:34:39 +08:00
Prevent NREs for null text (#8418)
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.
This commit is contained in:
parent
0d3f3ed9f3
commit
70c04a9a5f
@ -51,6 +51,7 @@ namespace Orchard.Localization.Services {
|
||||
|
||||
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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user