mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-24 01:52:22 +08:00
Fix encoding issue
"<none>" should go through the "T()" localizer --HG-- branch : dev
This commit is contained in:
parent
445dc41e36
commit
9413ef2984
@ -1,4 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Tests.Utility.Extensions {
|
||||
@ -27,16 +28,16 @@ namespace Orchard.Tests.Utility.Extensions {
|
||||
[Test]
|
||||
public void OrDefault_ReturnsDefaultForNull() {
|
||||
const string s = null;
|
||||
Assert.That(s.OrDefault("test"), Is.SameAs("test"));
|
||||
Assert.That(s.OrDefault(new LocalizedString("test")), Is.SameAs("test"));
|
||||
}
|
||||
[Test]
|
||||
public void OrDefault_ReturnsDefault() {
|
||||
Assert.That("".OrDefault("test"), Is.SameAs("test"));
|
||||
Assert.That("".OrDefault(new LocalizedString("test")), Is.SameAs("test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OrDefault_ReturnsString() {
|
||||
Assert.That("bar".OrDefault("test"), Is.SameAs("bar"));
|
||||
Assert.That("bar".OrDefault(new LocalizedString("test")), Is.SameAs("bar"));
|
||||
}
|
||||
[Test]
|
||||
public void IsNullOrEmptyTrimmed_EmptyStringReturnsTrue() {
|
||||
|
@ -27,16 +27,16 @@ namespace Orchard.Modules.Commands {
|
||||
Context.Output.WriteLine(T("List of available features"));
|
||||
Context.Output.WriteLine(T("--------------------------"));
|
||||
|
||||
var categories = _moduleService.GetAvailableFeatures().GroupBy(f => f.Descriptor.Category);
|
||||
var categories = _moduleService.GetAvailableFeatures().ToList().GroupBy(f => f.Descriptor.Category);
|
||||
foreach (var category in categories) {
|
||||
Context.Output.WriteLine(T("{0}", category.Key.OrDefault("General")));
|
||||
Context.Output.WriteLine(T("Category: {0}", category.Key.OrDefault(T("General"))));
|
||||
foreach (var feature in category.OrderBy(f => f.Descriptor.Name)) {
|
||||
Context.Output.WriteLine(T(" {0}", feature.Descriptor.Name));
|
||||
Context.Output.WriteLine(T(" Name: {0}", feature.Descriptor.Name));
|
||||
Context.Output.WriteLine(T(" State: {0}", feature.IsEnabled ? T("Enabled") : T("Disabled")));
|
||||
Context.Output.WriteLine(T(" Description: {0}", feature.Descriptor.Description.OrDefault("<none>")));
|
||||
Context.Output.WriteLine(T(" Category: {0}", feature.Descriptor.Category.OrDefault("<none>")));
|
||||
Context.Output.WriteLine(T(" Module: {0}", feature.Descriptor.Extension.Name.OrDefault("<none>")));
|
||||
Context.Output.WriteLine(T(" Dependencies: {0}", feature.Descriptor.Dependencies == null ? "<none>" : string.Join(",", feature.Descriptor.Dependencies).OrDefault("<none>")));
|
||||
Context.Output.WriteLine(T(" Description: {0}", feature.Descriptor.Description.OrDefault(T("<none>"))));
|
||||
Context.Output.WriteLine(T(" Category: {0}", feature.Descriptor.Category.OrDefault(T("<none>"))));
|
||||
Context.Output.WriteLine(T(" Module: {0}", feature.Descriptor.Extension.Name.OrDefault(T("<none>"))));
|
||||
Context.Output.WriteLine(T(" Dependencies: {0}", string.Join(", ", feature.Descriptor.Dependencies).OrDefault(T("<none>"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
namespace Orchard.Environment.Extensions.Models {
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Orchard.Environment.Extensions.Models {
|
||||
public class FeatureDescriptor {
|
||||
public FeatureDescriptor() {
|
||||
Dependencies = new string[0];
|
||||
Dependencies = Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
public ExtensionDescriptor Extension { get; set; }
|
||||
@ -9,6 +12,6 @@
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string[] Dependencies { get; set; }
|
||||
public IEnumerable<string> Dependencies { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Utility.Extensions {
|
||||
public static class StringExtensions {
|
||||
@ -24,10 +25,10 @@ namespace Orchard.Utility.Extensions {
|
||||
|| string.IsNullOrEmpty(text.Trim());
|
||||
}
|
||||
|
||||
public static string OrDefault(this string text, string defaultValue) {
|
||||
public static LocalizedString OrDefault(this string text, LocalizedString defaultValue) {
|
||||
return string.IsNullOrEmpty(text)
|
||||
? defaultValue
|
||||
: text;
|
||||
: new LocalizedString(text);
|
||||
}
|
||||
|
||||
public static string RemoveTags(this string html) {
|
||||
|
Loading…
Reference in New Issue
Block a user