From 8b187b30af53f7b3b9762e7595f29910b68d2cdc Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Sun, 31 Jul 2022 13:18:39 +0200 Subject: [PATCH] i18n --- CHANGELOG.md | 1 + VoiceAttack-Framework/L10n.Designer.cs | 153 ++++++++++++++++++ VoiceAttack-Framework/L10n.de.resx | 130 +++++++++++++++ VoiceAttack-Framework/L10n.resx | 138 ++++++++++++++++ .../VoiceAttack-Framework.csproj | 15 ++ VoiceAttack-Framework/VoiceAttackPlugin.cs | 43 +++-- 6 files changed, 457 insertions(+), 23 deletions(-) create mode 100644 VoiceAttack-Framework/L10n.Designer.cs create mode 100644 VoiceAttack-Framework/L10n.de.resx create mode 100644 VoiceAttack-Framework/L10n.resx diff --git a/CHANGELOG.md b/CHANGELOG.md index 502b001..dd31f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Added +* Localization. Currently ships with English and German. * [Commands interface](https://alternerdtive.github.io/YAVAPF/commands/). * Optionally suppress the race condition warning on [setting command scoped variables from the cached proxy diff --git a/VoiceAttack-Framework/L10n.Designer.cs b/VoiceAttack-Framework/L10n.Designer.cs new file mode 100644 index 0000000..0d06151 --- /dev/null +++ b/VoiceAttack-Framework/L10n.Designer.cs @@ -0,0 +1,153 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace alterNERDtive.Yavapf { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class L10n { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal L10n() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("alterNERDtive.Yavapf.L10n", typeof(L10n).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Error setting log level: '{0}' is not a valid log level.. + /// + internal static string ErrorSettingLogLevel { + get { + return ResourceManager.GetString("ErrorSettingLogLevel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Finished running Init handlers.. + /// + internal static string FinishedRunningInitHandlers { + get { + return ResourceManager.GetString("FinishedRunningInitHandlers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Initialized.. + /// + internal static string Initialized { + get { + return ResourceManager.GetString("Initialized", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid plugin context '{0}'.. + /// + internal static string InvalidPluginContext { + get { + return ResourceManager.GetString("InvalidPluginContext", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Missing parameter '{0}' for context '{1}'.. + /// + internal static string MissingParameterForContext { + get { + return ResourceManager.GetString("MissingParameterForContext", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Initializing v{0} …. + /// + internal static string PluginInitializing { + get { + return ResourceManager.GetString("PluginInitializing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Running Init handlers …. + /// + internal static string RunningInitHandlers { + get { + return ResourceManager.GetString("RunningInitHandlers", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unhandled exception while executing plugin context '{0}': {1}. + /// + internal static string UnhandledExceptionWhileExecutingPluginContext { + get { + return ResourceManager.GetString("UnhandledExceptionWhileExecutingPluginContext", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unhandled exception while handling changed {0} variable '{1}': {2}. + /// + internal static string UnhandledExceptionWhileHandlingChangedVariable { + get { + return ResourceManager.GetString("UnhandledExceptionWhileHandlingChangedVariable", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Accessing command scoped variable '{0}' outside of its context proxy object. This might lead to race conditions.. + /// + internal static string WarningCommandScopedVariable { + get { + return ResourceManager.GetString("WarningCommandScopedVariable", resourceCulture); + } + } + } +} diff --git a/VoiceAttack-Framework/L10n.de.resx b/VoiceAttack-Framework/L10n.de.resx new file mode 100644 index 0000000..93ce654 --- /dev/null +++ b/VoiceAttack-Framework/L10n.de.resx @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Fehler beim Setzen des Log Levels: '{0}' ist kein gültiger Log Level. + + + Initialisiert. + + + Ungültiger Plugin-Kontext '{0}'. + + + Parameter '{0}' für Kontext '{1}' fehlt. + + + Initialisiere v{0} … + + + Unbehandelte Ausnahme beim Ausführen von Plugin-Kontext '{0}': {1} + + + Unbehandelte Ausnahme bei der Behandlung der geänderten {0}-Variable '{1}': {2} + + + Zugriff auf Kommando-spezifische Variable '{0}' außerhalb ihres Kontext-Proxy-Objekts. + + + Führe Init-Handler aus … + + + Ausführen der Init-Handler abgeschloßen. + + \ No newline at end of file diff --git a/VoiceAttack-Framework/L10n.resx b/VoiceAttack-Framework/L10n.resx new file mode 100644 index 0000000..ba87d26 --- /dev/null +++ b/VoiceAttack-Framework/L10n.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Accessing command scoped variable '{0}' outside of its context proxy object. This might lead to race conditions. + 0: variable name + + + Initializing v{0} … + 0: plugin version + + + Running Init handlers … + + + + Finished running Init handlers. + + + Initialized. + + + Missing parameter '{0}' for context '{1}'. + 0: parameter name, 1: context name + + + Invalid plugin context '{0}'. + 0: context name + + + Unhandled exception while executing plugin context '{0}': {1} + 0: context name, 1: exception message + + + Unhandled exception while handling changed {0} variable '{1}': {2} + 0: type, 1: name, 2: exception message + + + Error setting log level: '{0}' is not a valid log level. + 0: log level + + \ No newline at end of file diff --git a/VoiceAttack-Framework/VoiceAttack-Framework.csproj b/VoiceAttack-Framework/VoiceAttack-Framework.csproj index 91029a4..46b7328 100644 --- a/VoiceAttack-Framework/VoiceAttack-Framework.csproj +++ b/VoiceAttack-Framework/VoiceAttack-Framework.csproj @@ -51,4 +51,19 @@ + + + True + True + L10n.resx + + + + + + ResXFileCodeGenerator + L10n.Designer.cs + + + diff --git a/VoiceAttack-Framework/VoiceAttackPlugin.cs b/VoiceAttack-Framework/VoiceAttackPlugin.cs index 0835bdf..8c3b5f8 100644 --- a/VoiceAttack-Framework/VoiceAttackPlugin.cs +++ b/VoiceAttack-Framework/VoiceAttackPlugin.cs @@ -155,8 +155,7 @@ namespace alterNERDtive.Yavapf { if (name.StartsWith("~") && !suppressWarning) { - this.Log.Warn( - $"Accessing command scoped variable '{name}' outside of its context proxy object. This might lead to race conditions."); + this.Log.Warn(string.Format(L10n.WarningCommandScopedVariable, name)); } return this.Proxy.Get(name); @@ -178,8 +177,7 @@ namespace alterNERDtive.Yavapf { if (name.StartsWith("~") && !suppressWarning) { - this.Log.Warn( - $"Accessing command scoped variable '{name}' outside of its context proxy object. This might lead to race conditions."); + this.Log.Warn(string.Format(L10n.WarningCommandScopedVariable, name)); } this.Proxy.Set(name, value); @@ -200,8 +198,7 @@ namespace alterNERDtive.Yavapf { if (name.StartsWith("~") && !suppressWarning) { - this.Log.Warn( - $"Accessing command scoped variable '{name}' outside of its context proxy object. This might lead to race conditions."); + this.Log.Warn(string.Format(L10n.WarningCommandScopedVariable, name)); } this.Proxy.Unset(name); @@ -235,7 +232,7 @@ namespace alterNERDtive.Yavapf this.vaProxy = vaProxy; this.Set($"{this.Name}.version", this.Version); - this.Log.Debug($"Initializing v{this.Version} …"); + this.Log.Debug(string.Format(L10n.PluginInitializing, this.Version)); this.vaProxy.BooleanVariableChanged += this.BooleanVariableChanged; this.vaProxy.DateVariableChanged += this.DateVariableChanged; @@ -270,12 +267,12 @@ namespace alterNERDtive.Yavapf this.GetType().GetMethods().Where(m => m.GetCustomAttributes().Any()).ToList().ForEach( m => this.StringChangedHandlers += (Action)m.CreateDelegate(typeof(Action))); - this.Log.Debug("Running Init handlers …"); + this.Log.Debug(L10n.RunningInitHandlers); this.InitActions?.Invoke(vaProxy); - this.Log.Debug("Finished running Init handlers."); + this.Log.Debug(L10n.FinishedRunningInitHandlers); this.Set($"{this.Name}.initialized", true); - this.Log.Debug("Initialized."); + this.Log.Debug(L10n.Initialized); } /// @@ -317,15 +314,15 @@ namespace alterNERDtive.Yavapf } catch (ArgumentNullException e) { - this.Log.Error($"Missing parameter '{e.ParamName}' for context '{context}'"); + this.Log.Error(string.Format(L10n.MissingParameterForContext, e.ParamName, context)); } catch (ArgumentException e) when (e.ParamName == "context") { - this.Log.Error($"Invalid plugin context '{vaProxy.Context}'."); + this.Log.Error(string.Format(L10n.InvalidPluginContext, vaProxy.Context)); } catch (Exception e) { - this.Log.Error($"Unhandled exception while executing plugin context '{context}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileExecutingPluginContext, context, e.Message)); } } else @@ -346,21 +343,21 @@ namespace alterNERDtive.Yavapf } catch (ArgumentNullException e) { - this.Log.Error($"Missing parameter '{e.ParamName}' for context '{context}'"); + this.Log.Error(string.Format(L10n.MissingParameterForContext, e.ParamName, context)); } catch (ArgumentException e) when (e.ParamName == "context") { - this.Log.Error($"Invalid plugin context '{vaProxy.Context}'."); + this.Log.Error(string.Format(L10n.InvalidPluginContext, vaProxy.Context)); } catch (Exception e) { - this.Log.Error($"Unhandled exception while executing plugin context '{context}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileExecutingPluginContext, context, e.Message)); } } } else { - this.Log.Error($"Invalid plugin context '{vaProxy.Context}'."); + this.Log.Error(string.Format(L10n.InvalidPluginContext, vaProxy.Context)); } } } @@ -406,7 +403,7 @@ namespace alterNERDtive.Yavapf } catch (Exception e) { - this.Log.Error($"Unhandled exception while handling changed bool variable '{name}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileHandlingChangedVariable, "bool", name, e.Message)); } } } @@ -432,7 +429,7 @@ namespace alterNERDtive.Yavapf } catch (Exception e) { - this.Log.Error($"Unhandled exception while handling changed DateTime variable '{name}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileHandlingChangedVariable, "DateTime", name, e.Message)); } } } @@ -458,7 +455,7 @@ namespace alterNERDtive.Yavapf } catch (Exception e) { - this.Log.Error($"Unhandled exception while handling changed decimal variable '{name}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileHandlingChangedVariable, "decimal", name, e.Message)); } } } @@ -484,7 +481,7 @@ namespace alterNERDtive.Yavapf } catch (Exception e) { - this.Log.Error($"Unhandled exception while handling changed int variable '{name}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileHandlingChangedVariable, "int", name, e.Message)); } } } @@ -506,7 +503,7 @@ namespace alterNERDtive.Yavapf } catch (ArgumentException) { - this.Log.Error($"Error setting log level: '{to!}' is not a valid log level."); + this.Log.Error(string.Format(L10n.ErrorSettingLogLevel, to)); } } @@ -522,7 +519,7 @@ namespace alterNERDtive.Yavapf } catch (Exception e) { - this.Log.Error($"Unhandled exception while handling changed string variable '{name}': {e.Message}"); + this.Log.Error(string.Format(L10n.UnhandledExceptionWhileHandlingChangedVariable, "string", name, e.Message)); } } }