From eb17f0b5b77f4e18f9ea13825e89b94b34f0cf92 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 13 Feb 2017 13:24:11 +0100 Subject: [PATCH] pokemon mostly localized, only strings which are constructed are left. --- src/NadekoBot/Modules/NadekoModule.cs | 38 +++- src/NadekoBot/Modules/Pokemon/Pokemon.cs | 67 +++---- .../Resources/ResponseStrings.Designer.cs | 188 +++++++++++++++++- src/NadekoBot/Resources/ResponseStrings.resx | 65 +++++- 4 files changed, 305 insertions(+), 53 deletions(-) diff --git a/src/NadekoBot/Modules/NadekoModule.cs b/src/NadekoBot/Modules/NadekoModule.cs index b5541b78..5ce45fb4 100644 --- a/src/NadekoBot/Modules/NadekoModule.cs +++ b/src/NadekoBot/Modules/NadekoModule.cs @@ -28,30 +28,48 @@ namespace NadekoBot.Modules : NadekoBot.Localization.GetCultureInfo(Context.Guild)); } - public Task ConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null) + //public Task ReplyConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null) + //{ + // var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo); + // var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + // return Context.Channel.SendConfirmAsync(title, text, url, footer); + //} + + //public Task ReplyConfirmLocalized(string textKey) + //{ + // var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + // return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + textKey); + //} + + //public Task ReplyErrorLocalized(string titleKey, string textKey, string url = null, string footer = null) + //{ + // var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo); + // var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); + // return Context.Channel.SendErrorAsync(title, text, url, footer); + //} + + public Task ErrorLocalized(string textKey, params object[] replacements) { - var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo); var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); - return Context.Channel.SendConfirmAsync(title, text, url, footer); + return Context.Channel.SendErrorAsync(string.Format(text, replacements)); } - public Task ConfirmLocalized(string textKey) + public Task ReplyErrorLocalized(string textKey, params object[] replacements) { var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); - return Context.Channel.SendConfirmAsync(textKey); + return Context.Channel.SendErrorAsync(Context.User.Mention + " " +string.Format(text, replacements)); } - public Task ErrorLocalized(string titleKey, string textKey, string url = null, string footer = null) + public Task ConfirmLocalized(string textKey, params object[] replacements) { - var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo); var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); - return Context.Channel.SendErrorAsync(title, text, url, footer); + return Context.Channel.SendConfirmAsync(string.Format(text, replacements)); } - public Task ErrorLocalized(string textKey) + public Task ReplyConfirmLocalized(string textKey, params object[] replacements) { var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); - return Context.Channel.SendErrorAsync(textKey); + return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + string.Format(text, replacements)); } } diff --git a/src/NadekoBot/Modules/Pokemon/Pokemon.cs b/src/NadekoBot/Modules/Pokemon/Pokemon.cs index 19515ad1..997f3570 100644 --- a/src/NadekoBot/Modules/Pokemon/Pokemon.cs +++ b/src/NadekoBot/Modules/Pokemon/Pokemon.cs @@ -107,12 +107,12 @@ namespace NadekoBot.Modules.Pokemon if (targetUser == null) { - await ErrorLocalized(nameof(ResponseStrings.Culture)).ConfigureAwait(false); + await ReplyErrorLocalized("user_not_found").ConfigureAwait(false); return; } - else if (targetUser == user) + if (targetUser == user) { - await ErrorLocalized("You can't attack yourself.").ConfigureAwait(false); + await ReplyErrorLocalized("cant_attack_yourself").ConfigureAwait(false); return; } @@ -126,17 +126,17 @@ namespace NadekoBot.Modules.Pokemon //User not able if HP < 0, has made more than 4 attacks if (userStats.Hp < 0) { - await Context.Channel.SendMessageAsync($"{user.Mention} has fainted and was not able to move!").ConfigureAwait(false); + await ReplyErrorLocalized("you_fainted").ConfigureAwait(false); return; } if (userStats.MovesMade >= 5) { - await Context.Channel.SendMessageAsync($"{user.Mention} has used too many moves in a row and was not able to move!").ConfigureAwait(false); + await ReplyErrorLocalized("too_many_moves").ConfigureAwait(false); return; } if (userStats.LastAttacked.Contains(targetUser.Id)) { - await Context.Channel.SendMessageAsync($"{user.Mention} can't attack again without retaliation!").ConfigureAwait(false); + await ReplyErrorLocalized("cant_attack_again").ConfigureAwait(false); return; } //get target stats @@ -146,7 +146,7 @@ namespace NadekoBot.Modules.Pokemon //If target's HP is below 0, no use attacking if (targetStats.Hp <= 0) { - await Context.Channel.SendMessageAsync($"{targetUser.Mention} has already fainted!").ConfigureAwait(false); + await ReplyErrorLocalized("too_many_moves", targetUser).ConfigureAwait(false); return; } @@ -156,7 +156,7 @@ namespace NadekoBot.Modules.Pokemon var enabledMoves = userType.Moves; if (!enabledMoves.Contains(move.ToLowerInvariant())) { - await Context.Channel.SendMessageAsync($"{user.Mention} is not able to use **{move}**. Type {NadekoBot.ModulePrefixes[typeof(Pokemon).Name]}ml to see moves").ConfigureAwait(false); + await ReplyErrorLocalized("invalid_move", move, _prefix).ConfigureAwait(false); return; } @@ -172,7 +172,7 @@ namespace NadekoBot.Modules.Pokemon //Damage type if (damage < 40) { - response += "\nIt's not effective.."; + response += "\nIt's not effective."; } else if (damage > 60) { @@ -235,7 +235,7 @@ namespace NadekoBot.Modules.Pokemon IGuildUser user = (IGuildUser)Context.User; if (targetUser == null) { - await Context.Channel.SendMessageAsync("No such person.").ConfigureAwait(false); + await ReplyErrorLocalized("user_not_found").ConfigureAwait(false); return; } @@ -244,7 +244,7 @@ namespace NadekoBot.Modules.Pokemon var targetStats = Stats[targetUser.Id]; if (targetStats.Hp == targetStats.MaxHp) { - await Context.Channel.SendMessageAsync($"{targetUser.Mention} already has full HP!").ConfigureAwait(false); + await ReplyErrorLocalized("already_full", targetUser).ConfigureAwait(false); return; } //Payment~ @@ -253,11 +253,11 @@ namespace NadekoBot.Modules.Pokemon var target = (targetUser.Id == user.Id) ? "yourself" : targetUser.Mention; if (amount > 0) { - if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false)) - { - try { await Context.Channel.SendMessageAsync($"{user.Mention} You don't have enough {NadekoBot.BotConfig.CurrencyName}s.").ConfigureAwait(false); } catch { } - return; - } + if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"Poke-Heal {target}", amount, true).ConfigureAwait(false)) + { + await ReplyErrorLocalized("no_currency", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); + return; + } } //healing @@ -268,20 +268,18 @@ namespace NadekoBot.Modules.Pokemon Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2); if (target == "yourself") { - await Context.Channel.SendMessageAsync($"You revived yourself with one {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); + await ReplyErrorLocalized("revive_yourself", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); + return; } - else - { - await Context.Channel.SendMessageAsync($"{user.Mention} revived {targetUser.Mention} with one {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); - } - return; + + await ReplyErrorLocalized("revive_other", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); } - await Context.Channel.SendMessageAsync($"{user.Mention} healed {targetUser.Mention} with one {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); + await ReplyErrorLocalized("healed", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); return; } else { - await Context.Channel.SendMessageAsync($"{targetUser.Mention} already has full HP!").ConfigureAwait(false); + await ErrorLocalized("already_full", targetUser); } } @@ -290,15 +288,9 @@ namespace NadekoBot.Modules.Pokemon [RequireContext(ContextType.Guild)] public async Task Type(IGuildUser targetUser = null) { - IGuildUser user = (IGuildUser)Context.User; - - if (targetUser == null) - { - return; - } - + targetUser = targetUser ?? (IGuildUser)Context.User; var pType = GetPokeType(targetUser.Id); - await Context.Channel.SendMessageAsync($"Type of {targetUser.Mention} is **{pType.Name.ToLowerInvariant()}**{pType.Icon}").ConfigureAwait(false); + await ReplyConfirmLocalized("type_of_user", targetUser.Mention, pType.Name.ToLowerInvariant() + pType.Icon).ConfigureAwait(false); } @@ -320,7 +312,7 @@ namespace NadekoBot.Modules.Pokemon } if (targetType == GetPokeType(user.Id)) { - await Context.Channel.SendMessageAsync($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Icon}").ConfigureAwait(false); + await ReplyErrorLocalized("already_that_type", targetType.Name.ToLowerInvariant() + targetType.Icon).ConfigureAwait(false); return; } @@ -328,9 +320,9 @@ namespace NadekoBot.Modules.Pokemon var amount = 1; if (amount > 0) { - if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user.Mention} change type to {typeTargeted}", amount, true).ConfigureAwait(false)) + if (!await CurrencyHandler.RemoveCurrencyAsync(user, $"{user} change type to {typeTargeted}", amount, true).ConfigureAwait(false)) { - try { await Context.Channel.SendMessageAsync($"{user.Mention} You don't have enough {NadekoBot.BotConfig.CurrencyName}s.").ConfigureAwait(false); } catch { } + await ReplyErrorLocalized("no_currency", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); return; } } @@ -363,9 +355,10 @@ namespace NadekoBot.Modules.Pokemon } //Now for the response - await Context.Channel.SendMessageAsync($"Set type of {user.Mention} to {typeTargeted}{targetType.Icon} for a {NadekoBot.BotConfig.CurrencySign}").ConfigureAwait(false); + await ReplyConfirmLocalized("settype_success", + typeTargeted + targetType.Icon, + NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); } - } } diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index 5b93ef8c..aab0ef1f 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -59,21 +59,201 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to {0} has already fainted.. + /// + public static string pokemon_already_fainted { + get { + return ResourceManager.GetString("pokemon_already_fainted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {1} already has full HP.. + /// + public static string pokemon_already_full { + get { + return ResourceManager.GetString("pokemon_already_full", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Your type is already {0}. + /// + public static string pokemon_already_that_type { + get { + return ResourceManager.GetString("pokemon_already_that_type", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to used **{0}**{1} on {2}{3} for **{4}** damage.. + /// + public static string pokemon_attack { + get { + return ResourceManager.GetString("pokemon_attack", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You can't attack again without retaliation!. + /// + public static string pokemon_cant_attack_again { + get { + return ResourceManager.GetString("pokemon_cant_attack_again", resourceCulture); + } + } + /// /// Looks up a localized string similar to You can't attack yourself.. /// - public static string cant_attack_yourself { + public static string pokemon_cant_attack_yourself { get { - return ResourceManager.GetString("cant_attack_yourself", resourceCulture); + return ResourceManager.GetString("pokemon_cant_attack_yourself", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} has fainted!. + /// + public static string pokemon_fainted { + get { + return ResourceManager.GetString("pokemon_fainted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} has {1} HP remaining.. + /// + public static string pokemon_hp_remaining { + get { + return ResourceManager.GetString("pokemon_hp_remaining", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You are not able to use **{0}**. Type {1}ml to see a list of moves you can use.. + /// + public static string pokemon_invalid_move { + get { + return ResourceManager.GetString("pokemon_invalid_move", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to It's not effective.. + /// + public static string pokemon_its_not_effective { + get { + return ResourceManager.GetString("pokemon_its_not_effective", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to It's somewhat effective.. + /// + public static string pokemon_its_somewhat_effective { + get { + return ResourceManager.GetString("pokemon_its_somewhat_effective", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to It's super effective!. + /// + public static string pokemon_its_super_effective { + get { + return ResourceManager.GetString("pokemon_its_super_effective", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Moves for {0} type. + /// + public static string pokemon_moves { + get { + return ResourceManager.GetString("pokemon_moves", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You don't have enough {0}. + /// + public static string pokemon_no_currency { + get { + return ResourceManager.GetString("pokemon_no_currency", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to revived {0} with one {1}. + /// + public static string pokemon_revive_other { + get { + return ResourceManager.GetString("pokemon_revive_other", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You revived yourself with one {0}. + /// + public static string pokemon_revive_yourself { + get { + return ResourceManager.GetString("pokemon_revive_yourself", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Your type has been changed to {0} for a {1}. + /// + public static string pokemon_settype_success { + get { + return ResourceManager.GetString("pokemon_settype_success", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You used too many moves in a row, so you can't move!. + /// + public static string pokemon_too_many_moves { + get { + return ResourceManager.GetString("pokemon_too_many_moves", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type of {0} is **{1}**. + /// + public static string pokemon_type_of_user { + get { + return ResourceManager.GetString("pokemon_type_of_user", resourceCulture); } } /// /// Looks up a localized string similar to User not found.. /// - public static string no_user_found { + public static string pokemon_user_not_found { get { - return ResourceManager.GetString("no_user_found", resourceCulture); + return ResourceManager.GetString("pokemon_user_not_found", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You fainted, so you are not able to move!. + /// + public static string pokemon_you_fainted { + get { + return ResourceManager.GetString("pokemon_you_fainted", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to healed {0} with one {1}. + /// + public static string pokmeon_healed { + get { + return ResourceManager.GetString("pokmeon_healed", resourceCulture); } } } diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index e740045d..69503270 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -117,10 +117,71 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + {0} has already fainted. + + + {1} already has full HP. + + + Your type is already {0} + + + used **{0}**{1} on {2}{3} for **{4}** damage. + Kwoth used punch:type_icon: on Sanity:type_icon: for 50 damage. + + + You can't attack again without retaliation! + + You can't attack yourself. - + + {0} has fainted! + + + {0} has {1} HP remaining. + + + You are not able to use **{0}**. Type {1}ml to see a list of moves you can use. + + + It's not effective. + + + It's somewhat effective. + + + It's super effective! + + + Moves for {0} type + + + You don't have enough {0} + + + revived {0} with one {1} + + + You revived yourself with one {0} + + + Your type has been changed to {0} for a {1} + + + You used too many moves in a row, so you can't move! + + + Type of {0} is **{1}** + + User not found. + + You fainted, so you are not able to move! + + + healed {0} with one {1} + \ No newline at end of file