- Correcting some localization calls to include formatted strings.

--HG--
branch : dev
This commit is contained in:
Suha Can
2010-06-02 11:48:10 -07:00
parent 417ab3eadf
commit 9c99b64044
3 changed files with 10 additions and 9 deletions

View File

@@ -25,10 +25,10 @@ namespace Orchard.Commands {
foreach (var commandSwitch in context.Switches.Keys) { foreach (var commandSwitch in context.Switches.Keys) {
PropertyInfo propertyInfo = GetType().GetProperty(commandSwitch); PropertyInfo propertyInfo = GetType().GetProperty(commandSwitch);
if (propertyInfo == null) { if (propertyInfo == null) {
throw new InvalidOperationException(T("Switch : ") + commandSwitch + T(" was not found")); throw new InvalidOperationException(T("Switch was not found: ") + commandSwitch);
} }
if (propertyInfo.GetCustomAttributes(typeof(OrchardSwitchAttribute), false).Length == 0) { if (propertyInfo.GetCustomAttributes(typeof(OrchardSwitchAttribute), false).Length == 0) {
throw new InvalidOperationException(T("A property of the name ") + commandSwitch + T(" exists but is not decorated with the OrchardSwitch attribute")); throw new InvalidOperationException(T("A property of this name exists but is not decorated with the OrchardSwitch attribute: ") + commandSwitch);
} }
string stringValue = context.Switches[commandSwitch]; string stringValue = context.Switches[commandSwitch];
if (propertyInfo.PropertyType.IsAssignableFrom(typeof(bool))) { if (propertyInfo.PropertyType.IsAssignableFrom(typeof(bool))) {
@@ -45,8 +45,7 @@ namespace Orchard.Commands {
propertyInfo.SetValue(this, stringValue, null); propertyInfo.SetValue(this, stringValue, null);
} }
else { else {
throw new InvalidOperationException(T("No property named ") + commandSwitch + throw new InvalidOperationException(T("No property named {0} found of type bool, int or string.", commandSwitch));
T(" found of type bool, int or string"));
} }
} }
} }
@@ -56,7 +55,7 @@ namespace Orchard.Commands {
CheckMethodForSwitches(context.CommandDescriptor.MethodInfo, context.Switches); CheckMethodForSwitches(context.CommandDescriptor.MethodInfo, context.Switches);
object[] invokeParameters = GetInvokeParametersForMethod(context.CommandDescriptor.MethodInfo, (context.Arguments ?? Enumerable.Empty<string>()).ToArray()); object[] invokeParameters = GetInvokeParametersForMethod(context.CommandDescriptor.MethodInfo, (context.Arguments ?? Enumerable.Empty<string>()).ToArray());
if (invokeParameters == null) { if (invokeParameters == null) {
throw new InvalidOperationException(T("Command arguments don't match").ToString()); throw new InvalidOperationException(T("Command arguments don't match"));
} }
this.Context = context; this.Context = context;
@@ -106,8 +105,7 @@ namespace Orchard.Commands {
} }
foreach (var commandSwitch in switches.Keys) { foreach (var commandSwitch in switches.Keys) {
if (!supportedSwitches.Contains(commandSwitch)) { if (!supportedSwitches.Contains(commandSwitch)) {
throw new InvalidOperationException(T("Method ") + methodInfo.Name + throw new InvalidOperationException(T("Method {0} does not support switch {1}.", methodInfo.Name, commandSwitch));
T(" does not support switch ") + commandSwitch);
} }
} }
} }

View File

@@ -9,7 +9,6 @@ using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Extensions.Models; using Orchard.Environment.Extensions.Models;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Logging; using Orchard.Logging;
using Yaml.Grammar;
using System.Web; using System.Web;
namespace Orchard.Environment.Extensions { namespace Orchard.Environment.Extensions {
@@ -54,7 +53,7 @@ namespace Orchard.Environment.Extensions {
private Feature LoadFeature(FeatureDescriptor featureDescriptor) { private Feature LoadFeature(FeatureDescriptor featureDescriptor) {
var featureName = featureDescriptor.Name; var featureName = featureDescriptor.Name;
string extensionName = GetExtensionForFeature(featureName); string extensionName = GetExtensionForFeature(featureName);
if (extensionName == null) throw new ArgumentException(T("Feature ") + featureName + T(" was not found in any of the installed extensions")); if (extensionName == null) throw new ArgumentException(T("Feature {0} was not found in any of the installed extensions", featureName));
var extension = BuildActiveExtensions().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault(); var extension = BuildActiveExtensions().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault();
if (extension == null) throw new InvalidOperationException(T("Extension ") + extensionName + T(" is not active")); if (extension == null) throw new InvalidOperationException(T("Extension ") + extensionName + T(" is not active"));

View File

@@ -16,6 +16,10 @@ namespace Orchard.Localization {
return _localized; return _localized;
} }
public static implicit operator string(LocalizedString x) {
return x._localized;
}
public override int GetHashCode() { public override int GetHashCode() {
var hashCode = 0; var hashCode = 0;
if (_localized != null) if (_localized != null)