mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
854 B
31 lines
854 B
using System;
|
|
using JetBrains.Annotations;
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
namespace Volo.Abp.Localization
|
|
{
|
|
public class LocalizableString : ILocalizableString
|
|
{
|
|
[CanBeNull]
|
|
public Type ResourceType { get; }
|
|
|
|
[NotNull]
|
|
public string Name { get; }
|
|
|
|
public LocalizableString(Type resourceType, [NotNull] string name)
|
|
{
|
|
Name = Check.NotNullOrEmpty(name, nameof(name));
|
|
ResourceType = resourceType;
|
|
}
|
|
|
|
public LocalizedString Localize(IStringLocalizerFactory stringLocalizerFactory)
|
|
{
|
|
return stringLocalizerFactory.Create(ResourceType)[Name];
|
|
}
|
|
|
|
public static LocalizableString Create<TResource>([NotNull] string name)
|
|
{
|
|
return new LocalizableString(typeof(TResource), name);
|
|
}
|
|
}
|
|
}
|