Localise text notifications.
This commit is contained in:
committed by
abcdefg30
parent
c041ea7d39
commit
44aaf4dd07
@@ -24,6 +24,9 @@ namespace OpenRA.Mods.Common.Commands
|
||||
{
|
||||
public Dictionary<string, IChatCommand> Commands { get; }
|
||||
|
||||
[TranslationReference("name")]
|
||||
static readonly string InvalidCommand = "invalid-command";
|
||||
|
||||
public ChatCommands()
|
||||
{
|
||||
Commands = new Dictionary<string, IChatCommand>();
|
||||
@@ -39,7 +42,7 @@ namespace OpenRA.Mods.Common.Commands
|
||||
if (command.Value != null)
|
||||
command.Value.InvokeCommand(name.ToLowerInvariant(), message.Substring(1 + name.Length).Trim());
|
||||
else
|
||||
TextNotificationsManager.Debug("{0} is not a valid command.", name);
|
||||
TextNotificationsManager.Debug(Game.ModData.Translation.GetString(InvalidCommand, Translation.Arguments("name", name)));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,12 @@ namespace OpenRA.Mods.Common.Commands
|
||||
|
||||
public class DevCommands : IChatCommand, IWorldLoaded
|
||||
{
|
||||
[TranslationReference]
|
||||
static readonly string CheatsDisabled = "cheats-disabled";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string InvalidCashAmount = "invalid-cash-amount";
|
||||
|
||||
readonly IDictionary<string, (string Description, Action<string, World> Handler)> commandHandlers = new Dictionary<string, (string, Action<string, World>)>
|
||||
{
|
||||
{ "visibility", ("toggles visibility checks and minimap.", Visibility) },
|
||||
@@ -70,7 +76,7 @@ namespace OpenRA.Mods.Common.Commands
|
||||
|
||||
if (!developerMode.Enabled)
|
||||
{
|
||||
TextNotificationsManager.Debug("Cheats are disabled.");
|
||||
TextNotificationsManager.Debug(Game.ModData.Translation.GetString(CheatsDisabled));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,7 +104,7 @@ namespace OpenRA.Mods.Common.Commands
|
||||
giveCashOrder.ExtraData = (uint)cash;
|
||||
else
|
||||
{
|
||||
TextNotificationsManager.Debug("Invalid amount of cash.");
|
||||
TextNotificationsManager.Debug(Game.ModData.Translation.GetString(InvalidCashAmount));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,12 @@ namespace OpenRA.Mods.Common.Commands
|
||||
{
|
||||
readonly Dictionary<string, string> helpDescriptions;
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string AvailableCommands = "available-commands";
|
||||
|
||||
[TranslationReference]
|
||||
static readonly string NoDescription = "no-description";
|
||||
|
||||
World world;
|
||||
ChatCommands console;
|
||||
|
||||
@@ -42,14 +48,14 @@ namespace OpenRA.Mods.Common.Commands
|
||||
|
||||
public void InvokeCommand(string name, string arg)
|
||||
{
|
||||
TextNotificationsManager.Debug("Here are the available commands:");
|
||||
TextNotificationsManager.Debug(Game.ModData.Translation.GetString(AvailableCommands));
|
||||
|
||||
foreach (var key in console.Commands.Keys)
|
||||
{
|
||||
if (!helpDescriptions.TryGetValue(key, out var description))
|
||||
description = "no description available.";
|
||||
description = Game.ModData.Translation.GetString(NoDescription);
|
||||
|
||||
TextNotificationsManager.Debug("{0}: {1}", key, description);
|
||||
TextNotificationsManager.Debug($"{key}: {description}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user