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