@ -11,6 +11,7 @@ using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc.UI.Alerts ;
using Volo.Abp.AspNetCore.Mvc.Validation ;
using Volo.Abp.Guids ;
using Volo.Abp.Localization ;
using Volo.Abp.MultiTenancy ;
using Volo.Abp.ObjectMapping ;
using Volo.Abp.Settings ;
@ -90,17 +91,29 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages
{
if ( _l ocalizer = = null )
{
if ( LocalizationResourceType = = null )
{
throw new AbpException ( $"{nameof(LocalizationResourceType)} should be set before using the {nameof(L)} object!" ) ;
}
_l ocalizer = StringLocalizerFactory . Create ( LocalizationResourceType ) ;
_l ocalizer = CreateLocalizer ( ) ;
}
return _l ocalizer ;
}
}
protected virtual IStringLocalizer CreateLocalizer ( )
{
if ( LocalizationResourceType ! = null )
{
return StringLocalizerFactory . Create ( LocalizationResourceType ) ;
}
var localizer = StringLocalizerFactory . CreateDefaultOrNull ( ) ;
if ( localizer = = null )
{
throw new AbpException ( $"Set {nameof(LocalizationResourceType)} or define the default localization resource type (by configuring the {nameof(AbpLocalizationOptions)}.{nameof(AbpLocalizationOptions.DefaultResourceType)}) to be able to use the {nameof(L)} object!" ) ;
}
return localizer ;
}
private IStringLocalizer _l ocalizer ;
protected Type LocalizationResourceType { get ; set ; }