using System; using System.Globalization; namespace Abp.Localization { /// /// Represents a string that can be localized. /// [Serializable] public class LocalizableString : ILocalizableString { /// /// Unique name of the localization source. /// public virtual string SourceName { get; private set; } /// /// Unique Name of the string to be localized. /// public virtual string Name { get; private set; } /// /// Needed for serialization. /// private LocalizableString() { } /// Unique Name of the string to be localized /// Unique name of the localization source public LocalizableString(string name, string sourceName) { if (name == null) { throw new ArgumentNullException("name"); } if (sourceName == null) { throw new ArgumentNullException("sourceName"); } Name = name; SourceName = sourceName; } public string Localize(ILocalizationContext context) { return context.LocalizationManager.GetString(SourceName, Name); } public string Localize(ILocalizationContext context, CultureInfo culture) { return context.LocalizationManager.GetString(SourceName, Name, culture); } public override string ToString() { return string.Format("[LocalizableString: {0}, {1}]", Name, SourceName); } } }