From 1eb9e673ec5815c4db3b75738a40d0d99342a967 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Sun, 29 Oct 2017 12:46:53 +0100 Subject: [PATCH] (GH-20) Added localization on a couple of hard coded strings fixes #20 --- .gitattributes | 3 + .gitignore | 4 + .tx/config | 15 +++ .../TransifexInitRunnerTests.cs | 2 +- src/Cake.Transifex/Cake.Transifex.csproj | 13 ++ src/Cake.Transifex/Common.Designer.cs | 73 +++++++++++ src/Cake.Transifex/Common.resx | 123 ++++++++++++++++++ src/Cake.Transifex/Exceptions.Designer.cs | 73 +++++++++++ src/Cake.Transifex/Exceptions.resx | 123 ++++++++++++++++++ src/Cake.Transifex/TransifexInitSettings.cs | 4 +- src/Cake.Transifex/TransifexRunner.cs | 4 +- src/Cake.Transifex/TransifexRunnerAliases.cs | 3 + 12 files changed, 435 insertions(+), 5 deletions(-) create mode 100644 .tx/config create mode 100644 src/Cake.Transifex/Common.Designer.cs create mode 100644 src/Cake.Transifex/Common.resx create mode 100644 src/Cake.Transifex/Exceptions.Designer.cs create mode 100644 src/Cake.Transifex/Exceptions.resx diff --git a/.gitattributes b/.gitattributes index 0630300..d35fca9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,6 +12,9 @@ ############################################################################### *.cs diff=csharp +*.resx text whitespace=-trailing-space +*.Designer.cs diff=csharp whitespace=-trailing-space + ############################################################################### # Set the merge driver for project and solution files # diff --git a/.gitignore b/.gitignore index b40eec2..470fe47 100644 --- a/.gitignore +++ b/.gitignore @@ -290,3 +290,7 @@ tools/** # Custom BuildArtifacts/ +*.*.resx +*.dll +*.hash +docs/input/tasks/ diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..f078280 --- /dev/null +++ b/.tx/config @@ -0,0 +1,15 @@ +[main] +host = https://www.transifex.com +lang_map = en_GB: en-GB, en_US: en-US + +[caketransifex.commonresx] +source_file = src/Cake.Transifex/Common.resx +file_filter = src/Cake.Transifex/Common..resx +source_lang = en +type = RESX + +[caketransifex.exceptionsresx] +source_file = src/Cake.Transifex/Exceptions.resx +file_filter = src/Cake.Transifex/Exceptions..resx +source_lang = en +type = RESX diff --git a/src/Cake.Transifex.Tests/TransifexInitRunnerTests.cs b/src/Cake.Transifex.Tests/TransifexInitRunnerTests.cs index 242c441..15eda2d 100644 --- a/src/Cake.Transifex.Tests/TransifexInitRunnerTests.cs +++ b/src/Cake.Transifex.Tests/TransifexInitRunnerTests.cs @@ -84,7 +84,7 @@ public void Evaluate_ThrowsArgumentExceptionWhenTokenAndUsernameOrPasswordIsSpec var ex = Assert.Throws(() => this.fixture.Run()); - Assert.Equal("A token can not be set at the same time as either the username or password.", ex.Message); + Assert.Equal(Exceptions.TokenAndUsernameException, ex.Message); } } } diff --git a/src/Cake.Transifex/Cake.Transifex.csproj b/src/Cake.Transifex/Cake.Transifex.csproj index 48cf56b..cfaeb86 100644 --- a/src/Cake.Transifex/Cake.Transifex.csproj +++ b/src/Cake.Transifex/Cake.Transifex.csproj @@ -53,4 +53,17 @@ To install the transifex client, install python, then run `pip install transifex + + + True + True + Exceptions.resx + + + + + ResXFileCodeGenerator + Exceptions.Designer.cs + + diff --git a/src/Cake.Transifex/Common.Designer.cs b/src/Cake.Transifex/Common.Designer.cs new file mode 100644 index 0000000..7ca6220 --- /dev/null +++ b/src/Cake.Transifex/Common.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// 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 Cake.Transifex { + using System; + using System.Reflection; + + + /// + /// 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", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Common { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Common() { + } + + /// + /// 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("Cake.Transifex.Common", typeof(Common).GetTypeInfo().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 Transifex Runner. + /// + internal static string TransifexRunner { + get { + return ResourceManager.GetString("TransifexRunner", resourceCulture); + } + } + } +} diff --git a/src/Cake.Transifex/Common.resx b/src/Cake.Transifex/Common.resx new file mode 100644 index 0000000..bffb545 --- /dev/null +++ b/src/Cake.Transifex/Common.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Transifex Runner + + \ No newline at end of file diff --git a/src/Cake.Transifex/Exceptions.Designer.cs b/src/Cake.Transifex/Exceptions.Designer.cs new file mode 100644 index 0000000..3b056cf --- /dev/null +++ b/src/Cake.Transifex/Exceptions.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// 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 Cake.Transifex { + using System; + using System.Reflection; + + + /// + /// 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", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Exceptions { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Exceptions() { + } + + /// + /// 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("Cake.Transifex.Exceptions", typeof(Exceptions).GetTypeInfo().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 A token can not be set at the same time as either the username or password.. + /// + internal static string TokenAndUsernameException { + get { + return ResourceManager.GetString("TokenAndUsernameException", resourceCulture); + } + } + } +} diff --git a/src/Cake.Transifex/Exceptions.resx b/src/Cake.Transifex/Exceptions.resx new file mode 100644 index 0000000..4336ee4 --- /dev/null +++ b/src/Cake.Transifex/Exceptions.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + A token can not be set at the same time as either the username or password. + + \ No newline at end of file diff --git a/src/Cake.Transifex/TransifexInitSettings.cs b/src/Cake.Transifex/TransifexInitSettings.cs index e3d8ea1..6c4e3ed 100644 --- a/src/Cake.Transifex/TransifexInitSettings.cs +++ b/src/Cake.Transifex/TransifexInitSettings.cs @@ -1,4 +1,4 @@ -namespace Cake.Transifex +namespace Cake.Transifex { using System; using Cake.Core; @@ -69,7 +69,7 @@ protected override void EvaluateCore(ProcessArgumentBuilder args) { if (!string.IsNullOrEmpty(Token) && (!string.IsNullOrEmpty(Username) || !string.IsNullOrEmpty(Password))) { - throw new ArgumentException("A token can not be set at the same time as either the username or password."); + throw new ArgumentException(Exceptions.TokenAndUsernameException); } if (!string.IsNullOrEmpty(Host)) diff --git a/src/Cake.Transifex/TransifexRunner.cs b/src/Cake.Transifex/TransifexRunner.cs index 775735f..ca23e37 100644 --- a/src/Cake.Transifex/TransifexRunner.cs +++ b/src/Cake.Transifex/TransifexRunner.cs @@ -1,4 +1,4 @@ -namespace Cake.Transifex +namespace Cake.Transifex { using System.Collections.Generic; using Cake.Core; @@ -69,7 +69,7 @@ protected override IEnumerable GetToolExecutableNames() }; protected override string GetToolName() - => "Transifex Runner"; + => Common.TransifexRunner; private static ProcessArgumentBuilder GetTransifexRunnerArguments(TransifexRunnerSettings settings) { diff --git a/src/Cake.Transifex/TransifexRunnerAliases.cs b/src/Cake.Transifex/TransifexRunnerAliases.cs index 8efffe7..1583059 100644 --- a/src/Cake.Transifex/TransifexRunnerAliases.cs +++ b/src/Cake.Transifex/TransifexRunnerAliases.cs @@ -28,6 +28,9 @@ public static class TransifexRunnerAliases /// ]]> /// /// + /// + /// Initial creation + /// public static void TransifexInit(this ICakeContext context) => TransifexInit(context, null);