mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Crowdin localization support (#2310)
* Switching to use resource files * Update Crowdin configuration file * Code cleanup
This commit is contained in:
parent
a27491c1b6
commit
077e3a5e9f
193 changed files with 102089 additions and 3564 deletions
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.Entities;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Exceptions;
|
||||
using Telegram.Bot.Polling;
|
||||
|
|
@ -93,13 +91,13 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
try
|
||||
{
|
||||
SendMessage(Translations.TryGet("bot.TelegramBridge.disconnected"));
|
||||
SendMessage(Translations.bot_TelegramBridge_disconnected);
|
||||
cancellationToken?.Cancel();
|
||||
botClient = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogToConsole("§w§l§f" + Translations.TryGet("bot.TelegramBridge.canceled_sending"));
|
||||
LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending);
|
||||
LogDebugToConsole(e);
|
||||
}
|
||||
|
||||
|
|
@ -120,34 +118,33 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
string direction = args[1].ToLower().Trim();
|
||||
|
||||
string? bridgeName = "";
|
||||
|
||||
string bridgeName;
|
||||
switch (direction)
|
||||
{
|
||||
case "b":
|
||||
case "both":
|
||||
bridgeName = "bot.TelegramBridge.direction.both";
|
||||
bridgeName = Translations.bot_TelegramBridge_direction_both;
|
||||
bridgeDirection = BridgeDirection.Both;
|
||||
break;
|
||||
|
||||
case "mc":
|
||||
case "minecraft":
|
||||
bridgeName = "bot.TelegramBridge.direction.minecraft";
|
||||
bridgeName = Translations.bot_TelegramBridge_direction_minecraft;
|
||||
bridgeDirection = BridgeDirection.Minecraft;
|
||||
break;
|
||||
|
||||
case "t":
|
||||
case "tg":
|
||||
case "telegram":
|
||||
bridgeName = "bot.TelegramBridge.direction.discord";
|
||||
bridgeName = Translations.bot_TelegramBridge_direction_Telegram;
|
||||
bridgeDirection = BridgeDirection.Telegram;
|
||||
break;
|
||||
|
||||
default:
|
||||
return Translations.TryGet("bot.TelegramBridge.invalid_direction");
|
||||
return Translations.bot_TelegramBridge_invalid_direction;
|
||||
}
|
||||
|
||||
return Translations.TryGet("bot.TelegramBridge.direction", Translations.TryGet(bridgeName));
|
||||
return string.Format(Translations.bot_TelegramBridge_direction, bridgeName);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +188,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogToConsole("§w§l§f" + Translations.TryGet("bot.TelegramBridge.canceled_sending"));
|
||||
LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending);
|
||||
LogDebugToConsole(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -214,7 +211,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogToConsole("§w§l§f" + Translations.TryGet("bot.TelegramBridge.canceled_sending"));
|
||||
LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending);
|
||||
LogDebugToConsole(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -230,13 +227,13 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
if (string.IsNullOrEmpty(Config.Token.Trim()))
|
||||
{
|
||||
LogToConsole(Translations.TryGet("bot.TelegramBridge.missing_token"));
|
||||
LogToConsole(Translations.bot_TelegramBridge_missing_token);
|
||||
UnloadBot();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Config.ChannelId.Trim()))
|
||||
LogToConsole("§w§l§f" + Translations.TryGet("bot.TelegramBridge.missing_channel_id"));
|
||||
LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_missing_channel_id);
|
||||
|
||||
botClient = new TelegramBotClient(Config.Token.Trim());
|
||||
cancellationToken = new CancellationTokenSource();
|
||||
|
|
@ -254,13 +251,13 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
IsConnected = true;
|
||||
|
||||
SendMessage("✅ " + Translations.TryGet("bot.TelegramBridge.connected"));
|
||||
LogToConsole("§y§l§f" + Translations.TryGet("bot.TelegramBridge.connected"));
|
||||
SendMessage($"✅ {Translations.bot_TelegramBridge_connected}");
|
||||
LogToConsole($"§y§l§f{Translations.bot_TelegramBridge_connected}");
|
||||
|
||||
if (Config.Authorized_Chat_Ids.Length == 0)
|
||||
{
|
||||
SendMessage("⚠️ *" + Translations.TryGet("bot.TelegramBridge.missing_authorized_channels") + "* ⚠️");
|
||||
LogToConsole("§w§l§f" + Translations.TryGet("bot.TelegramBridge.missing_authorized_channels"));
|
||||
SendMessage($"⚠️ *{Translations.bot_TelegramBridge_missing_authorized_channels}* ⚠️");
|
||||
LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_missing_authorized_channels}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +265,7 @@ namespace MinecraftClient.ChatBots
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogToConsole("§w§l§f" + Translations.TryGet("bot.TelegramBridge.unknown_error"));
|
||||
LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_unknown_error}");
|
||||
LogToConsole(e);
|
||||
return;
|
||||
}
|
||||
|
|
@ -309,7 +306,7 @@ namespace MinecraftClient.ChatBots
|
|||
await botClient.SendTextMessageAsync(
|
||||
chatId: chatId,
|
||||
replyToMessageId: message.MessageId,
|
||||
text: Translations.TryGet("bot.TelegramBridge.unauthorized"),
|
||||
text: Translations.bot_TelegramBridge_unauthorized,
|
||||
cancellationToken: _cancellationToken,
|
||||
parseMode: ParseMode.Markdown);
|
||||
return;
|
||||
|
|
@ -335,7 +332,7 @@ namespace MinecraftClient.ChatBots
|
|||
chatId: chatId,
|
||||
replyToMessageId:
|
||||
message.MessageId,
|
||||
text: $"{Translations.TryGet("bot.TelegramBridge.command_executed")}:\n\n{result}",
|
||||
text: $"{Translations.bot_TelegramBridge_command_executed}:\n\n{result}",
|
||||
cancellationToken: _cancellationToken,
|
||||
parseMode: ParseMode.Markdown);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue