Fixes, everything localized?
This commit is contained in:
		| @@ -14,12 +14,16 @@ namespace NadekoBot.Modules | ||||
|         protected readonly Logger _log; | ||||
|         public readonly string _prefix; | ||||
|         public readonly CultureInfo cultureInfo; | ||||
|         public readonly string ModuleTypeName; | ||||
|         public readonly string LowerModuleTypeName; | ||||
|  | ||||
|         public NadekoModule(bool isTopLevelModule = true) | ||||
|         { | ||||
|             //if it's top level module | ||||
|             var typeName = isTopLevelModule ? this.GetType().Name : this.GetType().DeclaringType.Name; | ||||
|             if (!NadekoBot.ModulePrefixes.TryGetValue(typeName, out _prefix)) | ||||
|             ModuleTypeName = isTopLevelModule ? this.GetType().Name : this.GetType().DeclaringType.Name; | ||||
|             LowerModuleTypeName = ModuleTypeName.ToLowerInvariant(); | ||||
|  | ||||
|             if (!NadekoBot.ModulePrefixes.TryGetValue(ModuleTypeName, out _prefix)) | ||||
|                 _prefix = "?err?"; | ||||
|             _log = LogManager.GetCurrentClassLogger(); | ||||
|  | ||||
| @@ -48,27 +52,37 @@ namespace NadekoBot.Modules | ||||
|         //    return Context.Channel.SendErrorAsync(title, text, url, footer); | ||||
|         //} | ||||
|  | ||||
|         protected string GetText(string key) | ||||
|         { | ||||
|             return NadekoBot.ResponsesResourceManager.GetString(LowerModuleTypeName + "_" + key, cultureInfo); | ||||
|         } | ||||
|  | ||||
|         protected string GetText(string key, params object[] replacements) | ||||
|         { | ||||
|             return string.Format(GetText(key), replacements); | ||||
|         } | ||||
|  | ||||
|         public Task<IUserMessage> ErrorLocalized(string textKey, params object[] replacements) | ||||
|         { | ||||
|             var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); | ||||
|             var text = GetText(textKey); | ||||
|             return Context.Channel.SendErrorAsync(string.Format(text, replacements)); | ||||
|         } | ||||
|  | ||||
|         public Task<IUserMessage> ReplyErrorLocalized(string textKey, params object[] replacements) | ||||
|         { | ||||
|             var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); | ||||
|             var text = GetText(textKey); | ||||
|             return Context.Channel.SendErrorAsync(Context.User.Mention + " " +string.Format(text, replacements)); | ||||
|         } | ||||
|  | ||||
|         public Task<IUserMessage> ConfirmLocalized(string textKey, params object[] replacements) | ||||
|         { | ||||
|             var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); | ||||
|             var text = GetText(textKey); | ||||
|             return Context.Channel.SendConfirmAsync(string.Format(text, replacements)); | ||||
|         } | ||||
|  | ||||
|         public Task<IUserMessage> ReplyConfirmLocalized(string textKey, params object[] replacements) | ||||
|         { | ||||
|             var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo); | ||||
|             var text = GetText(textKey); | ||||
|             return Context.Channel.SendConfirmAsync(Context.User.Mention + " " + string.Format(text, replacements)); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -166,32 +166,32 @@ namespace NadekoBot.Modules.Pokemon | ||||
|             int damage = GetDamage(userType, targetType); | ||||
|             //apply damage to target | ||||
|             targetStats.Hp -= damage; | ||||
|  | ||||
|             var response = $"{user.Mention} used **{move}**{userType.Icon} on {targetUser.Mention}{targetType.Icon} for **{damage}** damage"; | ||||
|              | ||||
|             var response = GetText("attack", move, userType.Icon, targetUser.Mention, targetType.Icon, damage); | ||||
|  | ||||
|             //Damage type | ||||
|             if (damage < 40) | ||||
|             { | ||||
|                 response += "\nIt's not effective."; | ||||
|                 response += "\n" + GetText("not_effective"); | ||||
|             } | ||||
|             else if (damage > 60) | ||||
|             { | ||||
|                 response += "\nIt's super effective!"; | ||||
|                 response += "\n" + GetText("super_effective"); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 response += "\nIt's somewhat effective"; | ||||
|                 response += "\n" + GetText("somewhat_effective"); | ||||
|             } | ||||
|  | ||||
|             //check fainted | ||||
|  | ||||
|             if (targetStats.Hp <= 0) | ||||
|             { | ||||
|                 response += $"\n**{targetUser.Mention}** has fainted!"; | ||||
|                 response += $"\n" + GetText("fainted", targetUser); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 response += $"\n**{targetUser.Mention}** has {targetStats.Hp} HP remaining"; | ||||
|                 response += $"\n" + GetText("hp_remaining", targetUser, targetStats.Hp); | ||||
|             } | ||||
|  | ||||
|             //update other stats | ||||
| @@ -208,7 +208,7 @@ namespace NadekoBot.Modules.Pokemon | ||||
|             Stats[user.Id] = userStats; | ||||
|             Stats[targetUser.Id] = targetStats; | ||||
|  | ||||
|             await Context.Channel.SendMessageAsync(response).ConfigureAwait(false); | ||||
|             await Context.Channel.SendConfirmAsync(Context.User.Mention + " " + response).ConfigureAwait(false); | ||||
|         } | ||||
|  | ||||
|  | ||||
| @@ -220,12 +220,10 @@ namespace NadekoBot.Modules.Pokemon | ||||
|  | ||||
|             var userType = GetPokeType(user.Id); | ||||
|             var movesList = userType.Moves; | ||||
|             var str = $"**Moves for `{userType.Name}` type.**"; | ||||
|             foreach (string m in movesList) | ||||
|             { | ||||
|                 str += $"\n{userType.Icon}{m}"; | ||||
|             } | ||||
|             await Context.Channel.SendMessageAsync(str).ConfigureAwait(false); | ||||
|             var embed = new EmbedBuilder().WithOkColor() | ||||
|                 .WithTitle(GetText("moves", userType)) | ||||
|                 .WithDescription(string.Join("\n", movesList.Select(m => userType.Icon + " " + m))); | ||||
|             await Context.Channel.EmbedAsync(embed).ConfigureAwait(false); | ||||
|         } | ||||
|  | ||||
|         [NadekoCommand, Usage, Description, Aliases] | ||||
| @@ -268,13 +266,13 @@ namespace NadekoBot.Modules.Pokemon | ||||
|                     Stats[targetUser.Id].Hp = (targetStats.MaxHp / 2); | ||||
|                     if (target == "yourself") | ||||
|                     { | ||||
|                         await ReplyErrorLocalized("revive_yourself", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); | ||||
|                         await ReplyConfirmLocalized("revive_yourself", NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); | ||||
|                         return; | ||||
|                     } | ||||
|  | ||||
|                     await ReplyErrorLocalized("revive_other", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); | ||||
|                     await ReplyConfirmLocalized("revive_other", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); | ||||
|                 } | ||||
|                 await ReplyErrorLocalized("healed", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); | ||||
|                 await ReplyConfirmLocalized("healed", targetUser, NadekoBot.BotConfig.CurrencySign).ConfigureAwait(false); | ||||
|                 return; | ||||
|             } | ||||
|             else | ||||
|   | ||||
							
								
								
									
										56
									
								
								src/NadekoBot/Resources/ResponseStrings.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										56
									
								
								src/NadekoBot/Resources/ResponseStrings.Designer.cs
									
									
									
										generated
									
									
									
								
							| @@ -141,34 +141,7 @@ namespace NadekoBot.Resources { | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to It's not effective.. | ||||
|         /// </summary> | ||||
|         public static string pokemon_its_not_effective { | ||||
|             get { | ||||
|                 return ResourceManager.GetString("pokemon_its_not_effective", resourceCulture); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to It's somewhat effective.. | ||||
|         /// </summary> | ||||
|         public static string pokemon_its_somewhat_effective { | ||||
|             get { | ||||
|                 return ResourceManager.GetString("pokemon_its_somewhat_effective", resourceCulture); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to It's super effective!. | ||||
|         /// </summary> | ||||
|         public static string pokemon_its_super_effective { | ||||
|             get { | ||||
|                 return ResourceManager.GetString("pokemon_its_super_effective", resourceCulture); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to Moves for {0} type. | ||||
|         ///    Looks up a localized string similar to Movelist for "{0}" type. | ||||
|         /// </summary> | ||||
|         public static string pokemon_moves { | ||||
|             get { | ||||
| @@ -185,6 +158,15 @@ namespace NadekoBot.Resources { | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to It's not effective.. | ||||
|         /// </summary> | ||||
|         public static string pokemon_not_effective { | ||||
|             get { | ||||
|                 return ResourceManager.GetString("pokemon_not_effective", resourceCulture); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to revived {0} with one {1}. | ||||
|         /// </summary> | ||||
| @@ -212,6 +194,24 @@ namespace NadekoBot.Resources { | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to It's somewhat effective.. | ||||
|         /// </summary> | ||||
|         public static string pokemon_somewhat_effective { | ||||
|             get { | ||||
|                 return ResourceManager.GetString("pokemon_somewhat_effective", resourceCulture); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to It's super effective!. | ||||
|         /// </summary> | ||||
|         public static string pokemon_super_effective { | ||||
|             get { | ||||
|                 return ResourceManager.GetString("pokemon_super_effective", resourceCulture); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         ///    Looks up a localized string similar to You used too many moves in a row, so you can't move!. | ||||
|         /// </summary> | ||||
|   | ||||
| @@ -145,17 +145,11 @@ | ||||
|   <data name="pokemon_invalid_move" xml:space="preserve"> | ||||
|     <value>You are not able to use **{0}**. Type {1}ml to see a list of moves you can use.</value> | ||||
|   </data> | ||||
|   <data name="pokemon_its_not_effective" xml:space="preserve"> | ||||
|     <value>It's not effective.</value> | ||||
|   </data> | ||||
|   <data name="pokemon_its_somewhat_effective" xml:space="preserve"> | ||||
|     <value>It's somewhat effective.</value> | ||||
|   </data> | ||||
|   <data name="pokemon_its_super_effective" xml:space="preserve"> | ||||
|     <value>It's super effective!</value> | ||||
|   </data> | ||||
|   <data name="pokemon_moves" xml:space="preserve"> | ||||
|     <value>Moves for {0} type</value> | ||||
|     <value>Movelist for "{0}" type</value> | ||||
|   </data> | ||||
|   <data name="pokemon_not_effective" xml:space="preserve"> | ||||
|     <value>It's not effective.</value> | ||||
|   </data> | ||||
|   <data name="pokemon_no_currency" xml:space="preserve"> | ||||
|     <value>You don't have enough {0}</value> | ||||
| @@ -169,6 +163,12 @@ | ||||
|   <data name="pokemon_settype_success" xml:space="preserve"> | ||||
|     <value>Your type has been changed to {0} for a {1}</value> | ||||
|   </data> | ||||
|   <data name="pokemon_somewhat_effective" xml:space="preserve"> | ||||
|     <value>It's somewhat effective.</value> | ||||
|   </data> | ||||
|   <data name="pokemon_super_effective" xml:space="preserve"> | ||||
|     <value>It's super effective!</value> | ||||
|   </data> | ||||
|   <data name="pokemon_too_many_moves" xml:space="preserve"> | ||||
|     <value>You used too many moves in a row, so you can't move!</value> | ||||
|   </data> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user