mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -4,11 +4,21 @@ using System.Web;
|
||||
namespace Orchard.Localization {
|
||||
public class LocalizedString : MarshalByRefObject, IHtmlString {
|
||||
private readonly string _localized;
|
||||
private readonly string _scope;
|
||||
private readonly string _textHint;
|
||||
private readonly object[] _args;
|
||||
|
||||
public LocalizedString(string localized) {
|
||||
_localized = localized;
|
||||
}
|
||||
|
||||
public LocalizedString(string localized, string scope, string textHint, object[] args) {
|
||||
_localized = localized;
|
||||
_scope = scope;
|
||||
_textHint = textHint;
|
||||
_args = args;
|
||||
}
|
||||
|
||||
public static LocalizedString TextOrDefault(string text, LocalizedString defaultValue) {
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return defaultValue;
|
||||
@@ -16,6 +26,18 @@ namespace Orchard.Localization {
|
||||
return new LocalizedString(text);
|
||||
}
|
||||
|
||||
public string Scope {
|
||||
get { return _scope; }
|
||||
}
|
||||
|
||||
public string TextHint {
|
||||
get { return _textHint; }
|
||||
}
|
||||
|
||||
public object[] Args {
|
||||
get { return _args; }
|
||||
}
|
||||
|
||||
public string Text {
|
||||
get { return _localized; }
|
||||
}
|
||||
|
@@ -27,8 +27,8 @@ namespace Orchard.Localization {
|
||||
var localizedFormat = _resourceManager.GetLocalizedString(_scope, textHint, currentCulture);
|
||||
|
||||
return args.Length == 0
|
||||
? new LocalizedString(localizedFormat)
|
||||
: new LocalizedString(string.Format(GetFormatProvider(currentCulture), localizedFormat, args.Select(Encode).ToArray()));
|
||||
? new LocalizedString(localizedFormat, _scope, textHint, args)
|
||||
: new LocalizedString(string.Format(GetFormatProvider(currentCulture), localizedFormat, args.Select(Encode).ToArray()), _scope, textHint, args);
|
||||
}
|
||||
|
||||
private static IFormatProvider GetFormatProvider(string currentCulture) {
|
||||
|
Reference in New Issue
Block a user