From 857e9a140f733dc6b519ccb6583f7974d6cf04ae Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sun, 25 Apr 2021 19:55:30 +0200 Subject: [PATCH] Initialize localization strings for STD plugin --- ...rm.OfficialPlugins.SteamTokenDumper.csproj | 15 ++ .../Localization/Strings.Designer.cs | 90 ++++++++++++ .../Localization/Strings.resx | 132 ++++++++++++++++++ .../SteamTokenDumperPlugin.cs | 26 ++-- ArchiSteamFarm/ArchiSteamFarm.csproj | 14 +- crowdin.yml | 8 ++ 6 files changed, 263 insertions(+), 22 deletions(-) create mode 100644 ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.Designer.cs create mode 100644 ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.resx diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj index ca694057f..dce27cb1a 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.csproj @@ -18,4 +18,19 @@ + + + + ResXFileCodeGenerator + Strings.Designer.cs + + + + + + True + Strings.resx + True + + diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.Designer.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.Designer.cs new file mode 100644 index 000000000..d7130b859 --- /dev/null +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// 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 ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.Localization { + 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", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Strings { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Strings() { + } + + /// + /// 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("ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.Localization.Strings", typeof(Strings).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 {0} is currently disabled according to your configuration. If you'd like to help SteamDB in data submission, please check out our wiki.. + /// + internal static string PluginDisabledInConfig { + get { + return ResourceManager.GetString("PluginDisabledInConfig", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} has been disabled due to a missing build token. + /// + internal static string PluginDisabledMissingBuildToken { + get { + return ResourceManager.GetString("PluginDisabledMissingBuildToken", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} has been initialized successfully, thank you in advance for your help. The first submission will happen in approximately {1} from now.. + /// + internal static string PluginInitializedAndEnabled { + get { + return ResourceManager.GetString("PluginInitializedAndEnabled", resourceCulture); + } + } + } +} diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.resx b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.resx new file mode 100644 index 000000000..ec8e39800 --- /dev/null +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + {0} has been disabled due to a missing build token + {0} will be replaced by the name of the plugin (e.g. "SteamTokenDumperPlugin") + + + {0} is currently disabled according to your configuration. If you'd like to help SteamDB in data submission, please check out our wiki. + {0} will be replaced by the name of the plugin (e.g. "SteamTokenDumperPlugin") + + + {0} has been initialized successfully, thank you in advance for your help. The first submission will happen in approximately {1} from now. + {0} will be replaced by the name of the plugin (e.g. "SteamTokenDumperPlugin"), {1} will be replaced by translated TimeSpan string (such as "53 minutes") + + diff --git a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs index 4ebf10c59..2aad5b5bb 100644 --- a/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs +++ b/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/SteamTokenDumperPlugin.cs @@ -29,7 +29,7 @@ using System.Linq; using System.Net; using System.Threading; using System.Threading.Tasks; -using ArchiSteamFarm.Localization; +using ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.Localization; using ArchiSteamFarm.Plugins; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -58,7 +58,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { public async void OnASFInit(IReadOnlyDictionary? additionalConfigProperties = null) { if (!SharedInfo.HasValidToken) { - ASF.ArchiLogger.LogGenericError($"{Name} has been disabled due to missing build token."); + ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.PluginDisabledMissingBuildToken, nameof(SteamTokenDumperPlugin))); return; } @@ -70,6 +70,8 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { try { if (configProperty == nameof(GlobalConfigExtension.SteamTokenDumperPluginEnabled)) { enabled = configValue.Value(); + + break; } } catch (Exception e) { ASF.ArchiLogger.LogGenericException(e); @@ -82,7 +84,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { IsEnabled = enabled; if (!enabled) { - ASF.ArchiLogger.LogGenericInfo($"{Name} is currently disabled. If you'd like to help SteamDB in data submission, check out our wiki for {nameof(SteamTokenDumperPlugin)}."); + ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginDisabledInConfig, nameof(SteamTokenDumperPlugin))); return; } @@ -95,7 +97,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { SubmissionTimer.Change(startIn, TimeSpan.FromHours(SharedInfo.MinimumHoursBetweenUploads)); } - ASF.ArchiLogger.LogGenericInfo($"{Name} has been initialized successfully, thank you for your help. The first submission will happen in approximately {startIn.ToHumanReadable()} from now."); + ASF.ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.PluginInitializedAndEnabled, nameof(SteamTokenDumperPlugin), startIn.ToHumanReadable())); } public async void OnBotDestroy(Bot bot) { @@ -304,12 +306,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { return; } - if (response == null) { - bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(response))); - - return; - } - bot.ArchiLogger.LogGenericInfo($"Finished retrieving {appIDsThisRound.Count} app access tokens."); appIDsThisRound.Clear(); @@ -350,7 +346,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { } if (response.Results == null) { - bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(response.Results))); + bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, ArchiSteamFarm.Localization.Strings.WarningFailedWithError, nameof(response.Results))); return; } @@ -463,13 +459,13 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { WebBrowser.ObjectResponse? response = await ASF.WebBrowser.UrlPostToJsonObject(request, data: requestData, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors).ConfigureAwait(false); if (response == null) { - ASF.ArchiLogger.LogGenericWarning(Strings.WarningFailed); + ASF.ArchiLogger.LogGenericWarning(ArchiSteamFarm.Localization.Strings.WarningFailed); return; } if (response.StatusCode.IsClientErrorCode()) { - ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, response.StatusCode)); + ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, ArchiSteamFarm.Localization.Strings.WarningFailedWithError, response.StatusCode)); #if NETFRAMEWORK if (response.StatusCode == (HttpStatusCode) 429) { @@ -489,13 +485,13 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper { } if (!response.Content.Success) { - ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsInvalid), nameof(response.Content.Success)); + ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, ArchiSteamFarm.Localization.Strings.ErrorIsInvalid), nameof(response.Content.Success)); return; } if (response.Content.Data == null) { - ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorIsInvalid), nameof(response.Content.Data)); + ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, ArchiSteamFarm.Localization.Strings.ErrorIsInvalid), nameof(response.Content.Data)); return; } diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj index 5bed19f41..36b39eb1e 100644 --- a/ArchiSteamFarm/ArchiSteamFarm.csproj +++ b/ArchiSteamFarm/ArchiSteamFarm.csproj @@ -48,6 +48,13 @@ + + + PublicResXFileCodeGenerator + Strings.Designer.cs + + + True @@ -56,13 +63,6 @@ - - - PublicResXFileCodeGenerator - Strings.Designer.cs - - - PreserveNewest diff --git a/crowdin.yml b/crowdin.yml index c6cfb603e..fd57ad2ba 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -8,6 +8,14 @@ ".sr-CS.resx": ".sr-Latn.resx" } }, + { + "source": "/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.resx", + "translation": "/ArchiSteamFarm.OfficialPlugins.SteamTokenDumper/Localization/Strings.%locale%.resx", + "translation_replace": { + ".lol-US.resx": ".qps-Ploc.resx", + ".sr-CS.resx": ".sr-Latn.resx" + } + }, { "source": "/wiki/*.md", "translation": "/wiki/locale/%locale%/%file_name%-%locale%.%file_extension%",