This commit is contained in:
alterNERDtive 2022-07-31 13:18:39 +02:00
parent 3328a0480c
commit 8b187b30af
Signed by: alterNERDtive
GPG key ID: 547787A4FE6533F1
6 changed files with 457 additions and 23 deletions

View file

@ -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

153
VoiceAttack-Framework/L10n.Designer.cs generated Normal file
View file

@ -0,0 +1,153 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace alterNERDtive.Yavapf {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Error setting log level: &apos;{0}&apos; is not a valid log level..
/// </summary>
internal static string ErrorSettingLogLevel {
get {
return ResourceManager.GetString("ErrorSettingLogLevel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Finished running Init handlers..
/// </summary>
internal static string FinishedRunningInitHandlers {
get {
return ResourceManager.GetString("FinishedRunningInitHandlers", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Initialized..
/// </summary>
internal static string Initialized {
get {
return ResourceManager.GetString("Initialized", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid plugin context &apos;{0}&apos;..
/// </summary>
internal static string InvalidPluginContext {
get {
return ResourceManager.GetString("InvalidPluginContext", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Missing parameter &apos;{0}&apos; for context &apos;{1}&apos;..
/// </summary>
internal static string MissingParameterForContext {
get {
return ResourceManager.GetString("MissingParameterForContext", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Initializing v{0} ….
/// </summary>
internal static string PluginInitializing {
get {
return ResourceManager.GetString("PluginInitializing", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Running Init handlers ….
/// </summary>
internal static string RunningInitHandlers {
get {
return ResourceManager.GetString("RunningInitHandlers", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unhandled exception while executing plugin context &apos;{0}&apos;: {1}.
/// </summary>
internal static string UnhandledExceptionWhileExecutingPluginContext {
get {
return ResourceManager.GetString("UnhandledExceptionWhileExecutingPluginContext", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unhandled exception while handling changed {0} variable &apos;{1}&apos;: {2}.
/// </summary>
internal static string UnhandledExceptionWhileHandlingChangedVariable {
get {
return ResourceManager.GetString("UnhandledExceptionWhileHandlingChangedVariable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Accessing command scoped variable &apos;{0}&apos; outside of its context proxy object. This might lead to race conditions..
/// </summary>
internal static string WarningCommandScopedVariable {
get {
return ResourceManager.GetString("WarningCommandScopedVariable", resourceCulture);
}
}
}
}

View file

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ErrorSettingLogLevel" xml:space="preserve">
<value>Fehler beim Setzen des Log Levels: '{0}' ist kein gültiger Log Level.</value>
</data>
<data name="Initialized" xml:space="preserve">
<value>Initialisiert.</value>
</data>
<data name="InvalidPluginContext" xml:space="preserve">
<value>Ungültiger Plugin-Kontext '{0}'.</value>
</data>
<data name="MissingParameterForContext" xml:space="preserve">
<value>Parameter '{0}' für Kontext '{1}' fehlt.</value>
</data>
<data name="PluginInitializing" xml:space="preserve">
<value>Initialisiere v{0} …</value>
</data>
<data name="UnhandledExceptionWhileExecutingPluginContext" xml:space="preserve">
<value>Unbehandelte Ausnahme beim Ausführen von Plugin-Kontext '{0}': {1}</value>
</data>
<data name="UnhandledExceptionWhileHandlingChangedVariable" xml:space="preserve">
<value>Unbehandelte Ausnahme bei der Behandlung der geänderten {0}-Variable '{1}': {2}</value>
</data>
<data name="WarningCommandScopedVariable" xml:space="preserve">
<value>Zugriff auf Kommando-spezifische Variable '{0}' außerhalb ihres Kontext-Proxy-Objekts.</value>
</data>
<data name="RunningInitHandlers" xml:space="preserve">
<value>Führe Init-Handler aus …</value>
</data>
<data name="FinishedRunningInitHandlers" xml:space="preserve">
<value>Ausführen der Init-Handler abgeschloßen.</value>
</data>
</root>

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="WarningCommandScopedVariable" xml:space="preserve">
<value>Accessing command scoped variable '{0}' outside of its context proxy object. This might lead to race conditions.</value>
<comment>0: variable name</comment>
</data>
<data name="PluginInitializing" xml:space="preserve">
<value>Initializing v{0} …</value>
<comment>0: plugin version</comment>
</data>
<data name="RunningInitHandlers" xml:space="preserve">
<value>Running Init handlers …</value>
</data>
<data name="FinishedRunningInitHandlers" xml:space="preserve">
<value>Finished running Init handlers.</value>
</data>
<data name="Initialized" xml:space="preserve">
<value>Initialized.</value>
</data>
<data name="MissingParameterForContext" xml:space="preserve">
<value>Missing parameter '{0}' for context '{1}'.</value>
<comment>0: parameter name, 1: context name</comment>
</data>
<data name="InvalidPluginContext" xml:space="preserve">
<value>Invalid plugin context '{0}'.</value>
<comment>0: context name</comment>
</data>
<data name="UnhandledExceptionWhileExecutingPluginContext" xml:space="preserve">
<value>Unhandled exception while executing plugin context '{0}': {1}</value>
<comment>0: context name, 1: exception message</comment>
</data>
<data name="UnhandledExceptionWhileHandlingChangedVariable" xml:space="preserve">
<value>Unhandled exception while handling changed {0} variable '{1}': {2}</value>
<comment>0: type, 1: name, 2: exception message</comment>
</data>
<data name="ErrorSettingLogLevel" xml:space="preserve">
<value>Error setting log level: '{0}' is not a valid log level.</value>
<comment>0: log level</comment>
</data>
</root>

View file

@ -51,4 +51,19 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="L10n.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>L10n.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="L10n.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>L10n.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View file

@ -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<T>(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<T>(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<T>(name);
@ -235,7 +232,7 @@ namespace alterNERDtive.Yavapf
this.vaProxy = vaProxy;
this.Set<string>($"{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<StringAttribute>().Any()).ToList().ForEach(
m => this.StringChangedHandlers += (Action<string, string?, string?>)m.CreateDelegate(typeof(Action<string, string?, string?>)));
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<bool>($"{this.Name}.initialized", true);
this.Log.Debug("Initialized.");
this.Log.Debug(L10n.Initialized);
}
/// <summary>
@ -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));
}
}
}