mirror of https://github.com/abpframework/abp.git
7 changed files with 74 additions and 7 deletions
@ -0,0 +1,19 @@ |
|||||
|
using Microsoft.Extensions.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.Localization |
||||
|
{ |
||||
|
public class FixedLocalizableString : ILocalizableString |
||||
|
{ |
||||
|
public string Value { get; } |
||||
|
|
||||
|
public FixedLocalizableString(string value) |
||||
|
{ |
||||
|
Value = value; |
||||
|
} |
||||
|
|
||||
|
public LocalizedString Localize(IStringLocalizerFactory stringLocalizerFactory) |
||||
|
{ |
||||
|
return new LocalizedString(Value, Value); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Microsoft.Extensions.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.Localization |
||||
|
{ |
||||
|
public interface ILocalizableString |
||||
|
{ |
||||
|
LocalizedString Localize(IStringLocalizerFactory stringLocalizerFactory); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
|
||||
|
namespace Volo.Abp.Localization |
||||
|
{ |
||||
|
public class LocalizableString : ILocalizableString |
||||
|
{ |
||||
|
public Type ResourceType { get; } |
||||
|
|
||||
|
public string Name { get; } |
||||
|
|
||||
|
public LocalizableString(Type resourceType, string name) |
||||
|
{ |
||||
|
ResourceType = resourceType; |
||||
|
Name = name; |
||||
|
} |
||||
|
|
||||
|
public LocalizedString Localize(IStringLocalizerFactory stringLocalizerFactory) |
||||
|
{ |
||||
|
return stringLocalizerFactory.Create(ResourceType)[Name]; |
||||
|
} |
||||
|
|
||||
|
public static LocalizableString Create<TResource>(string name) |
||||
|
{ |
||||
|
return new LocalizableString(typeof(TResource), name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue