- 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) {
PropertyInfo propertyInfo = GetType().GetProperty(commandSwitch);
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) {
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];
if (propertyInfo.PropertyType.IsAssignableFrom(typeof(bool))) {
@@ -45,8 +45,7 @@ namespace Orchard.Commands {
propertyInfo.SetValue(this, stringValue, null);
}
else {
throw new InvalidOperationException(T("No property named ") + commandSwitch +
T(" found of type bool, int or string"));
throw new InvalidOperationException(T("No property named {0} found of type bool, int or string.", commandSwitch));
}
}
}
@@ -56,7 +55,7 @@ namespace Orchard.Commands {
CheckMethodForSwitches(context.CommandDescriptor.MethodInfo, context.Switches);
object[] invokeParameters = GetInvokeParametersForMethod(context.CommandDescriptor.MethodInfo, (context.Arguments ?? Enumerable.Empty<string>()).ToArray());
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;
@@ -106,8 +105,7 @@ namespace Orchard.Commands {
}
foreach (var commandSwitch in switches.Keys) {
if (!supportedSwitches.Contains(commandSwitch)) {
throw new InvalidOperationException(T("Method ") + methodInfo.Name +
T(" does not support switch ") + commandSwitch);
throw new InvalidOperationException(T("Method {0} does not support switch {1}.", methodInfo.Name, commandSwitch));
}
}
}

View File

@@ -9,7 +9,6 @@ using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Extensions.Models;
using Orchard.Localization;
using Orchard.Logging;
using Yaml.Grammar;
using System.Web;
namespace Orchard.Environment.Extensions {
@@ -54,7 +53,7 @@ namespace Orchard.Environment.Extensions {
private Feature LoadFeature(FeatureDescriptor featureDescriptor) {
var featureName = featureDescriptor.Name;
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();
if (extension == null) throw new InvalidOperationException(T("Extension ") + extensionName + T(" is not active"));

View File

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