diff --git a/Compilation.Roslyn/Compilation.Roslyn.csproj b/Compilation.Roslyn/Compilation.Roslyn.csproj
index b62a2072..e14016f9 100644
--- a/Compilation.Roslyn/Compilation.Roslyn.csproj
+++ b/Compilation.Roslyn/Compilation.Roslyn.csproj
@@ -11,5 +11,6 @@
+
\ No newline at end of file
diff --git a/Compilation.Roslyn/RoslynCompiler.cs b/Compilation.Roslyn/RoslynCompiler.cs
index 674b4b8b..6d2a8380 100644
--- a/Compilation.Roslyn/RoslynCompiler.cs
+++ b/Compilation.Roslyn/RoslynCompiler.cs
@@ -11,6 +11,7 @@
using Ecng.Common;
using Ecng.Compilation;
+ using Ecng.Localization;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -137,7 +138,7 @@ byte[] getBody()
DiagnosticSeverity.Hidden or DiagnosticSeverity.Info => CompilationErrorTypes.Info,
DiagnosticSeverity.Warning => CompilationErrorTypes.Warning,
DiagnosticSeverity.Error => CompilationErrorTypes.Error,
- _ => throw new ArgumentOutOfRangeException(nameof(diagnostic), diagnostic.Severity, "Invalid value."),
+ _ => throw new ArgumentOutOfRangeException(nameof(diagnostic), diagnostic.Severity, "Invalid value.".Localize()),
}
};
diff --git a/ComponentModel/AsyncTimeout.cs b/ComponentModel/AsyncTimeout.cs
index fe55a6d1..f36a2893 100644
--- a/ComponentModel/AsyncTimeout.cs
+++ b/ComponentModel/AsyncTimeout.cs
@@ -3,6 +3,8 @@
using System;
using System.Threading;
+using Ecng.Localization;
+
public class AsyncTimeout
{
public TimeSpan Value { get; }
@@ -10,7 +12,7 @@ public class AsyncTimeout
public AsyncTimeout(TimeSpan value)
{
if (value <= TimeSpan.Zero)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
Value = value;
}
diff --git a/ComponentModel/ComponentModel.csproj b/ComponentModel/ComponentModel.csproj
index dc75a5ba..ff7a9ba9 100644
--- a/ComponentModel/ComponentModel.csproj
+++ b/ComponentModel/ComponentModel.csproj
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/ComponentModel/Extensions.cs b/ComponentModel/Extensions.cs
index 80fa6434..bab1ca35 100644
--- a/ComponentModel/Extensions.cs
+++ b/ComponentModel/Extensions.cs
@@ -11,6 +11,7 @@ namespace Ecng.ComponentModel
using Ecng.Collections;
using Ecng.Common;
using Ecng.Serialization;
+ using Ecng.Localization;
public static class Extensions
{
@@ -223,7 +224,7 @@ public static IEnumerable Typed(this PropertyDescriptorColle
throw new ArgumentNullException(nameof(instance));
if (maxDepth < 0)
- throw new ArgumentOutOfRangeException(nameof(maxDepth), maxDepth, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(maxDepth), maxDepth, "Invalid value.".Localize());
var properties = TypeDescriptor.GetProperties(instance, [new BasicSettingAttribute()]).Typed();
diff --git a/ComponentModel/OperatorRegistry.cs b/ComponentModel/OperatorRegistry.cs
index 3ac6ef2a..fab708bc 100644
--- a/ComponentModel/OperatorRegistry.cs
+++ b/ComponentModel/OperatorRegistry.cs
@@ -4,6 +4,7 @@ namespace Ecng.ComponentModel
using Ecng.Collections;
using Ecng.Common;
+ using Ecng.Localization;
public static class OperatorRegistry
{
@@ -114,7 +115,7 @@ public static void RemoveOperator(IOperator @operator)
public static long ThrowIfNegative(this long value, string name)
{
if (value < 0)
- throw new ArgumentOutOfRangeException(name, value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(name, value, "Invalid value.".Localize());
return value;
}
diff --git a/Ecng.sln b/Ecng.sln
index fc2c0d0d..a8850b6b 100644
--- a/Ecng.sln
+++ b/Ecng.sln
@@ -81,6 +81,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logging", "Logging\Logging.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.Utils", "Server.Utils\Server.Utils.csproj", "{3C29E094-0AA7-4CDA-ABD1-A684E8676A10}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Localization", "Localization\Localization.csproj", "{67E1B2C9-483E-4E8D-9617-C4AF7DC1EDC3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -231,6 +233,10 @@ Global
{3C29E094-0AA7-4CDA-ABD1-A684E8676A10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C29E094-0AA7-4CDA-ABD1-A684E8676A10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C29E094-0AA7-4CDA-ABD1-A684E8676A10}.Release|Any CPU.Build.0 = Release|Any CPU
+ {67E1B2C9-483E-4E8D-9617-C4AF7DC1EDC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {67E1B2C9-483E-4E8D-9617-C4AF7DC1EDC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {67E1B2C9-483E-4E8D-9617-C4AF7DC1EDC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {67E1B2C9-483E-4E8D-9617-C4AF7DC1EDC3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Localization/ILocalizer.cs b/Localization/ILocalizer.cs
new file mode 100644
index 00000000..159bf26a
--- /dev/null
+++ b/Localization/ILocalizer.cs
@@ -0,0 +1,6 @@
+namespace Ecng.Localization;
+
+public interface ILocalizer
+{
+ public string Localize(string enStr);
+}
\ No newline at end of file
diff --git a/Localization/Localization.csproj b/Localization/Localization.csproj
new file mode 100644
index 00000000..6877deff
--- /dev/null
+++ b/Localization/Localization.csproj
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Localization/LocalizedStrings.cs b/Localization/LocalizedStrings.cs
new file mode 100644
index 00000000..8d39cb50
--- /dev/null
+++ b/Localization/LocalizedStrings.cs
@@ -0,0 +1,39 @@
+namespace Ecng.Localization;
+
+using Ecng.Common;
+
+public static class LocalizedStrings
+{
+ public static ILocalizer Localizer { get; set; }
+
+ public const string InheritedKey = nameof(InheritedKey);
+ public const string VerboseKey = nameof(VerboseKey);
+ public const string DebugKey = nameof(DebugKey);
+ public const string InfoKey = nameof(InfoKey);
+ public const string WarningsKey = nameof(WarningsKey);
+ public const string ErrorsKey = nameof(ErrorsKey);
+ public const string OffKey = nameof(OffKey);
+ public const string IdKey = nameof(IdKey);
+ public const string LoggingKey = nameof(LoggingKey);
+ public const string NameKey = nameof(NameKey);
+ public const string LogSourceNameKey = nameof(LogSourceNameKey);
+ public const string LogLevelKey = nameof(LogLevelKey);
+ public const string LogLevelDescKey = nameof(LogLevelDescKey);
+
+ public static string Inherited => Localize(nameof(Inherited));
+ public static string Verbose => Localize(nameof(Verbose));
+ public static string Debug => Localize(nameof(Debug));
+ public static string Info => Localize(nameof(Info));
+ public static string Warnings => Localize(nameof(Warnings));
+ public static string Errors => Localize(nameof(Errors));
+ public static string Off => Localize(nameof(Off));
+ public static string Id => Localize(nameof(Id));
+ public static string Logging => Localize(nameof(Logging));
+ public static string Name => Localize(nameof(Name));
+ public static string LogSourceName => Localize(nameof(LogSourceName));
+ public static string LogLevel => Localize(nameof(LogLevel));
+ public static string LogLevelDesc => Localize(nameof(LogLevelDesc));
+
+ public static string Localize(this string enStr)
+ => (Localizer?.Localize(enStr)).IsEmpty(enStr);
+}
\ No newline at end of file
diff --git a/Logging/ConsoleLogListener.cs b/Logging/ConsoleLogListener.cs
index 96790b44..d1122558 100644
--- a/Logging/ConsoleLogListener.cs
+++ b/Logging/ConsoleLogListener.cs
@@ -1,5 +1,7 @@
namespace Ecng.Logging;
+using Ecng.Localization;
+
///
/// The logger that records the data to the console window.
///
@@ -26,7 +28,7 @@ protected override void OnWriteMessage(LogMessage message)
LogLevels.Verbose or LogLevels.Debug or LogLevels.Info => ConsoleHelper.Info,
LogLevels.Warning => ConsoleHelper.Warning,
LogLevels.Error => ConsoleHelper.Error,
- _ => throw new ArgumentOutOfRangeException(nameof(message), message.Level, "Invalid value."),
+ _ => throw new ArgumentOutOfRangeException(nameof(message), message.Level, "Invalid value.".Localize()),
};
var newLine = "{0} | {1, -15} | {2}".Put(message.Time.ToString(TimeFormat), message.Source.Name, message.Message);
diff --git a/Logging/DebugLogListener.cs b/Logging/DebugLogListener.cs
index e297b85b..856ebefc 100644
--- a/Logging/DebugLogListener.cs
+++ b/Logging/DebugLogListener.cs
@@ -2,6 +2,8 @@ namespace Ecng.Logging;
using System.Text;
+using Ecng.Localization;
+
///
/// The strategy logger that records the data to the debug window.
///
@@ -56,7 +58,7 @@ private static void Dump(LogLevels level, StringBuilder builder)
Trace.TraceError(str);
break;
default:
- throw new ArgumentOutOfRangeException(nameof(level), level, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(level), level, "Invalid value.".Localize());
}
builder.Clear();
diff --git a/Logging/FileLogListener.cs b/Logging/FileLogListener.cs
index 304b98dc..68cf3a8e 100644
--- a/Logging/FileLogListener.cs
+++ b/Logging/FileLogListener.cs
@@ -4,6 +4,8 @@ namespace Ecng.Logging;
using System.IO.Compression;
using System.Text;
+using Ecng.Localization;
+
///
/// Modes of log files splitting by date.
///
@@ -136,7 +138,7 @@ public long MaxLength
set
{
if (value < 0)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_maxLength = value;
}
@@ -153,7 +155,7 @@ public int MaxCount
set
{
if (value < 0)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_maxCount = value;
}
@@ -296,7 +298,7 @@ private string GetFileName(string sourceName, DateTime date)
Directory.CreateDirectory(dirName);
break;
default:
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(SeparateByDates), SeparateByDates, "Invalid value.".Localize());
}
fileName = Path.Combine(dirName, fileName);
@@ -330,7 +332,7 @@ private void TryDoHistoryPolicy()
isDir = true;
break;
default:
- throw new ArgumentOutOfRangeException(nameof(SeparateByDates), SeparateByDates, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(SeparateByDates), SeparateByDates, "Invalid value.".Localize());
}
if (SeparateByDates == SeparateByDateModes.None)
@@ -356,7 +358,7 @@ private void TryDoHistoryPolicy()
break;
}
default:
- throw new ArgumentOutOfRangeException(nameof(HistoryPolicy), policy, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(HistoryPolicy), policy, "Invalid value.".Localize());
}
var files = new List();
diff --git a/Logging/ILogSource.cs b/Logging/ILogSource.cs
index bcfc14ab..e36fd97c 100644
--- a/Logging/ILogSource.cs
+++ b/Logging/ILogSource.cs
@@ -1,8 +1,10 @@
namespace Ecng.Logging;
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using Ecng.ComponentModel;
+using Ecng.Localization;
///
/// Logs source interface.
@@ -65,12 +67,12 @@ protected BaseLogSource()
///
[Browsable(false)]
- //[Display(
- // ResourceType = typeof(LocalizedStrings),
- // Name = LocalizedStrings.IdKey,
- // Description = LocalizedStrings.IdKey,
- // GroupName = LocalizedStrings.LoggingKey,
- // Order = 1000)]
+ [Display(
+ ResourceType = typeof(LocalizedStrings),
+ Name = LocalizedStrings.IdKey,
+ Description = LocalizedStrings.IdKey,
+ GroupName = LocalizedStrings.LoggingKey,
+ Order = 1000)]
[ReadOnly(true)]
public virtual Guid Id { get; set; } = Guid.NewGuid();
@@ -78,12 +80,12 @@ protected BaseLogSource()
///
[ReadOnly(true)]
- //[Display(
- // ResourceType = typeof(LocalizedStrings),
- // Name = LocalizedStrings.NameKey,
- // Description = LocalizedStrings.LogSourceNameKey,
- // GroupName = LocalizedStrings.LoggingKey,
- // Order = 1001)]
+ [Display(
+ ResourceType = typeof(LocalizedStrings),
+ Name = LocalizedStrings.NameKey,
+ Description = LocalizedStrings.LogSourceNameKey,
+ GroupName = LocalizedStrings.LoggingKey,
+ Order = 1001)]
public virtual string Name
{
get => _name;
@@ -125,12 +127,12 @@ public ILogSource Parent
public event Action ParentRemoved;
///
- //[Display(
- // ResourceType = typeof(LocalizedStrings),
- // Name = LocalizedStrings.LogLevelKey,
- // Description = LocalizedStrings.LogLevelKey + LocalizedStrings.Dot,
- // GroupName = LocalizedStrings.LoggingKey,
- // Order = 1001)]
+ [Display(
+ ResourceType = typeof(LocalizedStrings),
+ Name = LocalizedStrings.LogLevelKey,
+ Description = LocalizedStrings.LogLevelDescKey,
+ GroupName = LocalizedStrings.LoggingKey,
+ Order = 1001)]
public virtual LogLevels LogLevel { get; set; } = LogLevels.Inherit;
///
diff --git a/Logging/LogLevels.cs b/Logging/LogLevels.cs
index 9eff4d98..002635fc 100644
--- a/Logging/LogLevels.cs
+++ b/Logging/LogLevels.cs
@@ -1,7 +1,10 @@
namespace Ecng.Logging;
+using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
+using Ecng.Localization;
+
///
/// Levels of log messages .
///
@@ -11,7 +14,7 @@ public enum LogLevels
///
/// To use the logging level of the container.
///
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.InheritedKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.InheritedKey)]
[EnumMember]
Inherit,
@@ -19,41 +22,41 @@ public enum LogLevels
/// Verbose message, debug message, information, warnings and errors.
///
[EnumMember]
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.VerboseKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.VerboseKey)]
Verbose,
///
/// Debug message, information, warnings and errors.
///
[EnumMember]
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.DebugKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.DebugKey)]
Debug,
///
/// Information, warnings and errors.
///
[EnumMember]
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.InfoKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.InfoKey)]
Info,
///
/// Warnings and errors.
///
[EnumMember]
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.WarningsKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.WarningsKey)]
Warning,
///
/// Errors only.
///
[EnumMember]
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.ErrorsKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.ErrorsKey)]
Error,
///
/// Logs off.
///
[EnumMember]
- //[Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.OffKey)]
+ [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.OffKey)]
Off,
}
\ No newline at end of file
diff --git a/Logging/Logging.csproj b/Logging/Logging.csproj
index 0e462266..64a9cc32 100644
--- a/Logging/Logging.csproj
+++ b/Logging/Logging.csproj
@@ -2,5 +2,6 @@
+
\ No newline at end of file
diff --git a/Logging/TraceSource.cs b/Logging/TraceSource.cs
index 83c15a8b..9cccdc68 100644
--- a/Logging/TraceSource.cs
+++ b/Logging/TraceSource.cs
@@ -1,5 +1,7 @@
namespace Ecng.Logging;
+using Ecng.Localization;
+
///
/// The logs source which receives information from .
///
@@ -48,7 +50,7 @@ public override void TraceEvent(TraceEventCache eventCache, string source, Trace
TraceEventType.Information => LogLevels.Info,
TraceEventType.Verbose => LogLevels.Debug,
TraceEventType.Start or TraceEventType.Stop or TraceEventType.Suspend or TraceEventType.Resume or TraceEventType.Transfer => null,
- _ => throw new ArgumentOutOfRangeException(nameof(eventType), eventType, "Invalid value."),
+ _ => throw new ArgumentOutOfRangeException(nameof(eventType), eventType, "Invalid value.".Localize()),
};
}
}
diff --git a/Net.SocketIO/Net.SocketIO.csproj b/Net.SocketIO/Net.SocketIO.csproj
index 585e2e19..e4decffc 100644
--- a/Net.SocketIO/Net.SocketIO.csproj
+++ b/Net.SocketIO/Net.SocketIO.csproj
@@ -7,6 +7,7 @@
+
diff --git a/Net.SocketIO/WebSocketClient.cs b/Net.SocketIO/WebSocketClient.cs
index eaf75ed5..2c769935 100644
--- a/Net.SocketIO/WebSocketClient.cs
+++ b/Net.SocketIO/WebSocketClient.cs
@@ -3,6 +3,7 @@
using System.Net.WebSockets;
using Ecng.Reflection;
+using Ecng.Localization;
public class WebSocketClient : Disposable, IConnection
{
@@ -94,7 +95,7 @@ public int ReconnectAttempts
set
{
if (value < -1)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_reconnectAttempts = value;
}
diff --git a/Net/RetryPolicyInfo.cs b/Net/RetryPolicyInfo.cs
index 197aa700..047f7d14 100644
--- a/Net/RetryPolicyInfo.cs
+++ b/Net/RetryPolicyInfo.cs
@@ -2,6 +2,8 @@
using System.Net.Sockets;
+using Ecng.Localization;
+
public class RetryPolicyInfo
{
private int _readMaxCount;
@@ -12,7 +14,7 @@ public int ReadMaxCount
set
{
if (value < 0)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_readMaxCount = value;
}
@@ -26,7 +28,7 @@ public int WriteMaxCount
set
{
if (value < 0)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_writeMaxCount = value;
}
@@ -40,7 +42,7 @@ public TimeSpan InitialDelay
set
{
if (value <= TimeSpan.Zero)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_initialDelay = value;
}
@@ -54,7 +56,7 @@ public TimeSpan MaxDelay
set
{
if (value <= TimeSpan.Zero)
- throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.");
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Invalid value.".Localize());
_maxDelay = value;
}