mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Preventing NRE in Text.cs
When WorkContext.Current is null
This commit is contained in:

committed by
Sebastien Ros

parent
4c16256245
commit
33648208f3
@@ -24,12 +24,17 @@ namespace Orchard.Localization {
|
||||
Logger.Debug("{0} localizing '{1}'", _scope, textHint);
|
||||
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
var currentCulture = workContext.CurrentCulture;
|
||||
var localizedFormat = _localizedStringManager.GetLocalizedString(_scope, textHint, currentCulture);
|
||||
|
||||
if (workContext != null) {
|
||||
var currentCulture = workContext.CurrentCulture;
|
||||
var localizedFormat = _localizedStringManager.GetLocalizedString(_scope, textHint, currentCulture);
|
||||
|
||||
return args.Length == 0
|
||||
? new LocalizedString(localizedFormat, _scope, textHint, args)
|
||||
: new LocalizedString(string.Format(GetFormatProvider(currentCulture), localizedFormat, args), _scope, textHint, args);
|
||||
return args.Length == 0
|
||||
? new LocalizedString(localizedFormat, _scope, textHint, args)
|
||||
: new LocalizedString(string.Format(GetFormatProvider(currentCulture), localizedFormat, args), _scope, textHint, args);
|
||||
}
|
||||
|
||||
return new LocalizedString(textHint, _scope, textHint, args);
|
||||
}
|
||||
|
||||
private static IFormatProvider GetFormatProvider(string currentCulture) {
|
||||
|
Reference in New Issue
Block a user