Crowdin localization support (#2310)

* Switching to use resource files

* Update Crowdin configuration file

* Code cleanup
This commit is contained in:
BruceChen 2022-10-28 11:13:20 +08:00 committed by GitHub
parent a27491c1b6
commit 077e3a5e9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
193 changed files with 102089 additions and 3564 deletions

View file

@ -47,7 +47,7 @@ namespace MinecraftClient.Protocol.Handlers.Forge
Version = fmlVersion;
break;
default:
throw new InvalidOperationException(Translations.Get("error.forgeforce"));
throw new InvalidOperationException(Translations.error_forgeforce);
}
}

View file

@ -48,7 +48,7 @@ namespace MinecraftClient.Protocol.Handlers
{
PacketTypePalette p;
if (protocol > Protocol18Handler.MC_1_19_2_Version)
throw new NotImplementedException(Translations.Get("exception.palette.packet"));
throw new NotImplementedException(Translations.exception_palette_packet);
if (protocol <= Protocol18Handler.MC_1_8_Version)
p = new PacketPalette17();

View file

@ -43,19 +43,19 @@ namespace MinecraftClient.Protocol.Handlers
if (Handler.GetTerrainEnabled())
{
Translations.WriteLineFormatted("extra.terrainandmovement_disabled");
ConsoleIO.WriteLineFormatted(Translations.extra_terrainandmovement_disabled, acceptnewlines: true);
Handler.SetTerrainEnabled(false);
}
if (handler.GetInventoryEnabled())
{
Translations.WriteLineFormatted("extra.inventory_disabled");
ConsoleIO.WriteLineFormatted(Translations.extra_inventory_disabled, acceptnewlines: true);
handler.SetInventoryEnabled(false);
}
if (handler.GetEntityHandlingEnabled())
{
Translations.WriteLineFormatted("extra.entity_disabled");
ConsoleIO.WriteLineFormatted(Translations.extra_entity_disabled, acceptnewlines: true);
handler.SetEntityHandlingEnabled(false);
}
}
@ -184,7 +184,7 @@ namespace MinecraftClient.Protocol.Handlers
case 0x84: ReadData(11); nbr = ReadNextShort(); if (nbr > 0) { ReadData(nbr); } break;
case 0x85: if (protocolversion >= 74) { ReadData(13); } break;
case 0xC8:
if (ReadNextInt() == 2022) { Translations.WriteLogLine("mcc.player_dead"); }
if (ReadNextInt() == 2022) { ConsoleIO.WriteLogLine(Translations.mcc_player_dead, acceptnewlines: true); }
if (protocolversion >= 72) { ReadData(4); } else ReadData(1);
break;
case 0xC9:
@ -494,15 +494,15 @@ namespace MinecraftClient.Protocol.Handlers
byte[] token = ReadNextByteArray();
if (serverID == "-")
Translations.WriteLineFormatted("mcc.server_offline");
ConsoleIO.WriteLineFormatted(Translations.mcc_server_offline, acceptnewlines: true);
else if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.handshake", serverID));
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_handshake, serverID));
return StartEncryption(uuid, username, sessionID, token, serverID, PublicServerkey, session);
}
else
{
Translations.WriteLineFormatted("error.invalid_response");
ConsoleIO.WriteLineFormatted(Translations.error_invalid_response, acceptnewlines: true);
return false;
}
}
@ -513,11 +513,11 @@ namespace MinecraftClient.Protocol.Handlers
byte[] secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("debug.crypto");
ConsoleIO.WriteLineFormatted(Translations.debug_crypto, acceptnewlines: true);
if (serverIDhash != "-")
{
Translations.WriteLine("mcc.session");
ConsoleIO.WriteLine(Translations.mcc_session);
string serverHash = CryptoHandler.GetServerHash(serverIDhash, serverPublicKey, secretKey);
bool needCheckSession = true;
@ -539,7 +539,7 @@ namespace MinecraftClient.Protocol.Handlers
}
else
{
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, Translations.Get("mcc.session_fail"));
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, Translations.mcc_session_fail);
return false;
}
}
@ -578,7 +578,7 @@ namespace MinecraftClient.Protocol.Handlers
}
else
{
Translations.WriteLineFormatted("error.invalid_encrypt");
ConsoleIO.WriteLineFormatted(Translations.error_invalid_encrypt, acceptnewlines: true);
return false;
}
}
@ -891,7 +891,7 @@ namespace MinecraftClient.Protocol.Handlers
version = "B1.8.1 - 1.3.2";
}
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.use_version", version, protocolversion));
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_use_version, version, protocolversion));
return true;
}

View file

@ -107,24 +107,24 @@ namespace MinecraftClient.Protocol.Handlers
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_19_2_Version)
{
log.Error(Translations.Get("extra.terrainandmovement_disabled"));
log.Error(Translations.extra_terrainandmovement_disabled);
handler.SetTerrainEnabled(false);
}
if (handler.GetInventoryEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_2_Version))
{
log.Error(Translations.Get("extra.inventory_disabled"));
log.Error(Translations.extra_inventory_disabled);
handler.SetInventoryEnabled(false);
}
if (handler.GetEntityHandlingEnabled() && (protocolVersion < MC_1_10_Version || protocolVersion > MC_1_19_2_Version))
{
log.Error(Translations.Get("extra.entity_disabled"));
log.Error(Translations.extra_entity_disabled);
handler.SetEntityHandlingEnabled(false);
}
// Block palette
if (protocolVersion > MC_1_19_2_Version && handler.GetTerrainEnabled())
throw new NotImplementedException(Translations.Get("exception.palette.block"));
throw new NotImplementedException(Translations.exception_palette_block);
if (protocolVersion >= MC_1_19_Version)
Block.Palette = new Palette119();
@ -143,7 +143,7 @@ namespace MinecraftClient.Protocol.Handlers
// Entity palette
if (protocolVersion > MC_1_19_2_Version && handler.GetEntityHandlingEnabled())
throw new NotImplementedException(Translations.Get("exception.palette.entity"));
throw new NotImplementedException(Translations.exception_palette_entity);
if (protocolVersion >= MC_1_19_Version)
entityPalette = new EntityPalette119();
@ -164,7 +164,7 @@ namespace MinecraftClient.Protocol.Handlers
// Item palette
if (protocolVersion > MC_1_19_2_Version && handler.GetInventoryEnabled())
throw new NotImplementedException(Translations.Get("exception.palette.item"));
throw new NotImplementedException(Translations.exception_palette_item);
if (protocolVersion >= MC_1_19_Version)
itemPalette = new ItemPalette119();
@ -587,7 +587,7 @@ namespace MinecraftClient.Protocol.Handlers
bool lastVerifyResult = player.IsMessageChainLegal();
verifyResult = player.VerifyMessage(signedChat, timestamp, salt, ref headerSignature, ref precedingSignature, lastSeenMessages);
if (lastVerifyResult && !verifyResult)
log.Warn(Translations.Get("chat.message_chain_broken", senderDisplayName));
log.Warn(string.Format(Translations.chat_message_chain_broken, senderDisplayName));
}
}
@ -649,7 +649,7 @@ namespace MinecraftClient.Protocol.Handlers
bool lastVerifyResult = player.IsMessageChainLegal();
verifyResult = player.VerifyMessageHead(ref precedingSignature, ref headerSignature, ref bodyDigest);
if (lastVerifyResult && !verifyResult)
log.Warn(Translations.Get("chat.message_chain_broken", player.Name));
log.Warn(string.Format(Translations.chat_message_chain_broken, player.Name));
}
}
}
@ -1647,7 +1647,7 @@ namespace MinecraftClient.Protocol.Handlers
int healthField; // See https://wiki.vg/Entity_metadata#Living_Entity
if (protocolVersion > MC_1_19_2_Version)
throw new NotImplementedException(Translations.Get("exception.palette.healthfield"));
throw new NotImplementedException(Translations.exception_palette_healthfield);
else if (protocolVersion >= MC_1_17_Version) // 1.17 and above
healthField = 9;
else if (protocolVersion >= MC_1_14_Version) // 1.14 and above
@ -1655,7 +1655,7 @@ namespace MinecraftClient.Protocol.Handlers
else if (protocolVersion >= MC_1_10_Version) // 1.10 and above
healthField = 7;
else
throw new NotImplementedException(Translations.Get("exception.palette.healthfield"));
throw new NotImplementedException(Translations.exception_palette_healthfield);
if (metadata.TryGetValue(healthField, out object? healthObj) && healthObj != null && healthObj.GetType() == typeof(float))
handler.OnEntityHealth(EntityID, (float)healthObj);
@ -1788,7 +1788,7 @@ namespace MinecraftClient.Protocol.Handlers
if (innerException is ThreadAbortException || innerException is SocketException || innerException.InnerException is SocketException)
throw; //Thread abort or Connection lost rather than invalid data
throw new System.IO.InvalidDataException(
Translations.Get("exception.packet_process",
string.Format(Translations.exception_packet_process,
packetPalette.GetIncommingTypeById(packetID),
packetID,
protocolVersion,
@ -1953,12 +1953,12 @@ namespace MinecraftClient.Protocol.Handlers
}
else if (packetID == 0x02) //Login successful
{
log.Info(Translations.Get("mcc.server_offline"));
log.Info(Translations.mcc_server_offline);
login_phase = false;
if (!pForge.CompleteForgeHandshake())
{
log.Error(Translations.Get("error.forge"));
log.Error(Translations.error_forge);
return false;
}
@ -1978,11 +1978,11 @@ namespace MinecraftClient.Protocol.Handlers
RSACryptoServiceProvider RSAService = CryptoHandler.DecodeRSAPublicKey(serverPublicKey)!;
byte[] secretKey = CryptoHandler.ClientAESPrivateKey ?? CryptoHandler.GenerateAESPrivateKey();
log.Debug(Translations.Get("debug.crypto"));
log.Debug(Translations.debug_crypto);
if (serverIDhash != "-")
{
log.Info(Translations.Get("mcc.session"));
log.Info(Translations.mcc_session);
bool needCheckSession = true;
if (session.ServerPublicKey != null && session.SessionPreCheckTask != null
@ -2005,7 +2005,7 @@ namespace MinecraftClient.Protocol.Handlers
}
else
{
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, Translations.Get("mcc.session_fail"));
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, Translations.mcc_session_fail);
return false;
}
}
@ -2047,7 +2047,7 @@ namespace MinecraftClient.Protocol.Handlers
(int packetID, Queue<byte> packetData) = ReadNextPacket();
if (packetID < 0 || loopPrevention-- < 0) // Failed to read packet or too many iterations (issue #1150)
{
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.Get("error.invalid_encrypt"));
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.error_invalid_encrypt);
return false;
}
else if (packetID == 0x00) //Login rejected
@ -2083,7 +2083,7 @@ namespace MinecraftClient.Protocol.Handlers
if (!pForge.CompleteForgeHandshake())
{
log.Error(Translations.Get("error.forge_encrypt"));
log.Error(Translations.error_forge_encrypt);
return false;
}
@ -2221,7 +2221,7 @@ namespace MinecraftClient.Protocol.Handlers
// Check for forge on the server.
Protocol18Forge.ServerInfoCheckForge(jsonData, ref forgeInfo);
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.server_protocol", version, protocolVersion + (forgeInfo != null ? Translations.Get("mcc.with_forge") : "")));
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_server_protocol, version, protocolVersion + (forgeInfo != null ? Translations.mcc_with_forge : "")));
return true;
}

View file

@ -131,7 +131,7 @@ namespace MinecraftClient.Protocol.Handlers
byte fmlProtocolVersion = dataTypes.ReadNextByte(packetData);
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("forge.version", fmlProtocolVersion));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_version, fmlProtocolVersion));
if (fmlProtocolVersion >= 1)
currentDimension = dataTypes.ReadNextInt(packetData);
@ -141,7 +141,7 @@ namespace MinecraftClient.Protocol.Handlers
// Then tell the server that we're running the same mods.
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("forge.send_mod");
ConsoleIO.WriteLineFormatted(Translations.forge_send_mod, acceptnewlines: true);
byte[][] mods = new byte[forgeInfo.Mods.Count][];
for (int i = 0; i < forgeInfo.Mods.Count; i++)
{
@ -161,7 +161,7 @@ namespace MinecraftClient.Protocol.Handlers
Thread.Sleep(2000);
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("forge.accept");
ConsoleIO.WriteLineFormatted(Translations.forge_accept, acceptnewlines: true);
// Tell the server that yes, we are OK with the mods it has
// even though we don't actually care what mods it has.
@ -183,7 +183,7 @@ namespace MinecraftClient.Protocol.Handlers
int registrySize = dataTypes.ReadNextVarInt(packetData);
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("forge.registry", registrySize));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_registry, registrySize));
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
}
@ -195,7 +195,7 @@ namespace MinecraftClient.Protocol.Handlers
string registryName = dataTypes.ReadNextString(packetData);
int registrySize = dataTypes.ReadNextVarInt(packetData);
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("forge.registry_2", registryName, registrySize));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_registry_2, registryName, registrySize));
if (!hasNextRegistry)
fmlHandshakeState = FMLHandshakeClientState.PENDINGCOMPLETE;
}
@ -207,7 +207,7 @@ namespace MinecraftClient.Protocol.Handlers
if (discriminator != FMLHandshakeDiscriminator.HandshakeAck)
return false;
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("forge.accept_registry");
ConsoleIO.WriteLineFormatted(Translations.forge_accept_registry, acceptnewlines: true);
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
new byte[] { (byte)FMLHandshakeClientState.PENDINGCOMPLETE });
fmlHandshakeState = FMLHandshakeClientState.COMPLETE;
@ -221,7 +221,7 @@ namespace MinecraftClient.Protocol.Handlers
SendForgeHandshakePacket(FMLHandshakeDiscriminator.HandshakeAck,
new byte[] { (byte)FMLHandshakeClientState.COMPLETE });
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLine("forge.complete");
ConsoleIO.WriteLine(Translations.forge_complete);
fmlHandshakeState = FMLHandshakeClientState.DONE;
return true;
}
@ -301,7 +301,7 @@ namespace MinecraftClient.Protocol.Handlers
// [1]: Version is usually set to "FML2" for FML stuff and "1" for mods
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("forge.fml2.mod");
ConsoleIO.WriteLineFormatted(Translations.forge_fml2_mod, acceptnewlines: true);
List<string> mods = new();
int modCount = dataTypes.ReadNextVarInt(packetData);
@ -333,7 +333,7 @@ namespace MinecraftClient.Protocol.Handlers
// In MCC, we just want to send a valid response so we'll reply back with data collected from the server.
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("forge.fml2.mod_send");
ConsoleIO.WriteLineFormatted(Translations.forge_fml2_mod_send, acceptnewlines: true);
// Packet ID 2: Client to Server Mod List
fmlResponsePacket.AddRange(dataTypes.GetVarInt(2));
@ -371,7 +371,7 @@ namespace MinecraftClient.Protocol.Handlers
if (Settings.Config.Logging.DebugMessages)
{
string registryName = dataTypes.ReadNextString(packetData);
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.registry", registryName));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_registry, registryName));
}
fmlResponsePacket.AddRange(dataTypes.GetVarInt(99));
@ -390,7 +390,7 @@ namespace MinecraftClient.Protocol.Handlers
if (Settings.Config.Logging.DebugMessages)
{
string configName = dataTypes.ReadNextString(packetData);
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.config", configName));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_config, configName));
}
fmlResponsePacket.AddRange(dataTypes.GetVarInt(99));
@ -399,7 +399,7 @@ namespace MinecraftClient.Protocol.Handlers
default:
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.unknown", packetID));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_unknown, packetID));
break;
}
@ -415,7 +415,7 @@ namespace MinecraftClient.Protocol.Handlers
}
else if (Settings.Config.Logging.DebugMessages)
{
ConsoleIO.WriteLineFormatted(Translations.Get("forge.fml2.unknown_channel", fmlChannel));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_fml2_unknown_channel, fmlChannel));
}
}
return false;
@ -464,7 +464,7 @@ namespace MinecraftClient.Protocol.Handlers
{
return new ForgeInfo(FMLVersion.FML2);
}
else throw new InvalidOperationException(Translations.Get("error.forgeforce"));
else throw new InvalidOperationException(Translations.error_forgeforce);
}
/// <summary>
@ -504,10 +504,10 @@ namespace MinecraftClient.Protocol.Handlers
forgeInfo = new ForgeInfo(modData, fmlVersion);
if (forgeInfo.Mods.Any())
{
ConsoleIO.WriteLineFormatted(Translations.Get("forge.with_mod", forgeInfo.Mods.Count));
ConsoleIO.WriteLineFormatted(string.Format(Translations.forge_with_mod, forgeInfo.Mods.Count));
if (Settings.Config.Logging.DebugMessages)
{
Translations.WriteLineFormatted("forge.mod_list");
ConsoleIO.WriteLineFormatted(Translations.forge_mod_list, acceptnewlines: true);
foreach (ForgeInfo.ForgeMod mod in forgeInfo.Mods)
ConsoleIO.WriteLineFormatted("§8 " + mod.ToString());
}
@ -515,7 +515,7 @@ namespace MinecraftClient.Protocol.Handlers
}
else
{
Translations.WriteLineFormatted("forge.no_mod");
ConsoleIO.WriteLineFormatted(Translations.forge_no_mod, acceptnewlines: true);
forgeInfo = null;
}
}

View file

@ -219,7 +219,7 @@ namespace MinecraftClient.Protocol
//File not found? Try downloading language file from Mojang's servers?
if (!File.Exists(Language_File))
{
ConsoleIO.WriteLineFormatted(Translations.Get("chat.download", Config.Main.Advanced.Language));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_download, Config.Main.Advanced.Language));
HttpClient httpClient = new();
try
{
@ -233,7 +233,7 @@ namespace MinecraftClient.Protocol
string hash = tmp[1].Split('"')[0]; //Translations file identifier on Mojang's servers
string translation_file_location = Settings.TranslationsFile_Website_Download + '/' + hash[..2] + '/' + hash;
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("chat.request", translation_file_location));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_request, translation_file_location));
Task<string> fetch_file = httpClient.GetStringAsync(translation_file_location);
fetch_file.Wait();
@ -245,11 +245,11 @@ namespace MinecraftClient.Protocol
stringBuilder.Append(entry.Key).Append('=').Append(entry.Value.StringValue.Replace("\n", "\\n").Replace("\r", String.Empty)).Append(Environment.NewLine);
File.WriteAllText(Language_File, stringBuilder.ToString());
ConsoleIO.WriteLineFormatted(Translations.Get("chat.done", Language_File));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_done, Language_File));
}
catch
{
Translations.WriteLineFormatted("chat.fail");
ConsoleIO.WriteLineFormatted(Translations.chat_fail, acceptnewlines: true);
}
httpClient.Dispose();
}
@ -259,7 +259,7 @@ namespace MinecraftClient.Protocol
&& File.Exists(Settings.TranslationsFile_FromMCDir))
{
Language_File = Settings.TranslationsFile_FromMCDir;
Translations.WriteLineFormatted("chat.from_dir");
ConsoleIO.WriteLineFormatted(Translations.chat_from_dir, acceptnewlines: true);
}
//Load the external dictionnary of translation rules or display an error message
@ -278,11 +278,11 @@ namespace MinecraftClient.Protocol
}
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("chat.loaded");
ConsoleIO.WriteLineFormatted(Translations.chat_loaded, acceptnewlines: true);
}
else //No external dictionnary found.
{
ConsoleIO.WriteLineFormatted(Translations.Get("chat.not_found", Language_File));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_not_found, Language_File));
}
}

View file

@ -116,7 +116,7 @@ namespace MinecraftClient.Protocol.Keys
if (File.Exists(KeysCacheFilePlaintext))
{
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loading_keys", KeysCacheFilePlaintext));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loading_keys, KeysCacheFilePlaintext));
try
{
@ -135,35 +135,35 @@ namespace MinecraftClient.Protocol.Keys
PlayerKeyPair playerKeyPair = PlayerKeyPair.FromString(value);
keys[login] = playerKeyPair;
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded_keys", playerKeyPair.ExpiresAt.ToString()));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loaded_keys, playerKeyPair.ExpiresAt.ToString()));
}
catch (InvalidDataException e)
{
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_string_keys", value, e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string_keys, value, e.Message));
}
catch (FormatException e)
{
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_string_keys", value, e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string_keys, value, e.Message));
}
catch (ArgumentNullException e)
{
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_string_keys", value, e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string_keys, value, e.Message));
}
}
else if (Settings.Config.Logging.DebugMessages)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_line_keys", line));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_line_keys, line));
}
}
}
}
catch (IOException e)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.read_fail_plain_keys", e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_read_fail_plain_keys, e.Message));
}
}
@ -176,7 +176,7 @@ namespace MinecraftClient.Protocol.Keys
private static void SaveToDisk()
{
if (Config.Logging.DebugMessages)
Translations.WriteLineFormatted("cache.saving_keys");
ConsoleIO.WriteLineFormatted(Translations.cache_saving_keys, acceptnewlines: true);
List<string> KeysCacheLines = new()
{
@ -192,7 +192,7 @@ namespace MinecraftClient.Protocol.Keys
}
catch (IOException e)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.save_fail_keys", e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_save_fail_keys, e.Message));
}
}
}

View file

@ -44,7 +44,7 @@ namespace MinecraftClient.Protocol
{
try
{
Translations.WriteLine("mcc.resolve", domainVal);
ConsoleIO.WriteLine(string.Format(Translations.mcc_resolve, domainVal));
var lookupClient = new LookupClient();
var response = lookupClient.Query(new DnsQuestion($"_minecraft._tcp.{domainVal}", QueryType.SRV));
if (response.HasError != true && response.Answers.SrvRecords().Any())
@ -56,7 +56,7 @@ namespace MinecraftClient.Protocol
.ThenBy(record => Guid.NewGuid())
.First();
string target = result.Target.Value.Trim('.');
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.found", target, result.Port, domainVal));
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_found, target, result.Port, domainVal));
domainVal = target;
portVal = result.Port;
foundService = true;
@ -64,7 +64,7 @@ namespace MinecraftClient.Protocol
}
catch (Exception e)
{
ConsoleIO.WriteLineFormatted(Translations.Get("mcc.not_found", domainVal, e.GetType().FullName, e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.mcc_not_found, domainVal, e.GetType().FullName, e.Message));
}
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30));
}
@ -95,7 +95,8 @@ namespace MinecraftClient.Protocol
{
success = true;
}
else Translations.WriteLineFormatted("error.unexpect_response");
else
ConsoleIO.WriteLineFormatted(Translations.error_unexpect_response, acceptnewlines: true);
}
catch (Exception e)
{
@ -104,9 +105,9 @@ namespace MinecraftClient.Protocol
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30)))
{
if (protocolversion != 0 && protocolversion != protocolversionTmp)
Translations.WriteLineFormatted("error.version_different");
ConsoleIO.WriteLineFormatted(Translations.error_version_different, acceptnewlines: true);
if (protocolversion == 0 && protocolversionTmp <= 1)
Translations.WriteLineFormatted("error.no_version_report");
ConsoleIO.WriteLineFormatted(Translations.error_no_version_report, acceptnewlines: true);
if (protocolversion == 0)
protocolversion = protocolversionTmp;
forgeInfo = forgeInfoTmp;
@ -114,7 +115,7 @@ namespace MinecraftClient.Protocol
}
else
{
Translations.WriteLineFormatted("error.connection_timeout");
ConsoleIO.WriteLineFormatted(Translations.error_connection_timeout, acceptnewlines: true);
return false;
}
}
@ -138,7 +139,7 @@ namespace MinecraftClient.Protocol
if (Array.IndexOf(supportedVersions_Protocol18, ProtocolVersion) > -1)
return new Protocol18Handler(Client, ProtocolVersion, Handler, forgeInfo);
throw new NotSupportedException(Translations.Get("exception.version_unsupport", ProtocolVersion));
throw new NotSupportedException(string.Format(Translations.exception_version_unsupport, ProtocolVersion));
}
/// <summary>
@ -490,7 +491,7 @@ namespace MinecraftClient.Protocol
}
else
{
ConsoleIO.WriteLineFormatted(Translations.Get("error.http_code", code));
ConsoleIO.WriteLineFormatted(string.Format(Translations.error_http_code, code));
return LoginResult.OtherError;
}
}
@ -692,7 +693,7 @@ namespace MinecraftClient.Protocol
}
else
{
ConsoleIO.WriteLineFormatted(Translations.Get("error.auth", code));
ConsoleIO.WriteLineFormatted(string.Format(Translations.error_auth, code));
return LoginResult.OtherError;
}
}
@ -763,10 +764,10 @@ namespace MinecraftClient.Protocol
}
if (availableWorlds.Count > 0)
{
Translations.WriteLine("mcc.realms_available");
ConsoleIO.WriteLine(Translations.mcc_realms_available);
foreach (var world in availableWorlds)
ConsoleIO.WriteLine(world);
Translations.WriteLine("mcc.realms_join");
ConsoleIO.WriteLine(Translations.mcc_realms_join);
}
}
@ -804,13 +805,13 @@ namespace MinecraftClient.Protocol
return serverAddress.Properties["address"].StringValue;
else
{
Translations.WriteLine("error.realms.ip_error");
ConsoleIO.WriteLine(Translations.error_realms_ip_error);
return "";
}
}
else
{
Translations.WriteLine("error.realms.access_denied");
ConsoleIO.WriteLine(Translations.error_realms_access_denied);
return "";
}
}
@ -893,7 +894,7 @@ namespace MinecraftClient.Protocol
try
{
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("debug.request", host));
ConsoleIO.WriteLineFormatted(string.Format(Translations.debug_request, host));
TcpClient client = ProxyHandler.NewTcpClient(host, 443, true);
SslStream stream = new(client.GetStream());

View file

@ -125,7 +125,7 @@ namespace MinecraftClient.Protocol.Session
if (File.Exists(SessionCacheFileMinecraft))
{
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loading", Path.GetFileName(SessionCacheFileMinecraft)));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loading, Path.GetFileName(SessionCacheFileMinecraft)));
Json.JSONData mcSession = new(Json.JSONData.DataType.String);
try
{
@ -158,7 +158,7 @@ namespace MinecraftClient.Protocol.Session
clientID
));
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded", login, session.ID));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loaded, login, session.ID));
sessions[login] = session;
}
catch (InvalidDataException) { /* Not a valid session */ }
@ -172,7 +172,7 @@ namespace MinecraftClient.Protocol.Session
if (File.Exists(SessionCacheFileSerialized))
{
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.converting", SessionCacheFileSerialized));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_converting, SessionCacheFileSerialized));
try
{
@ -184,17 +184,17 @@ namespace MinecraftClient.Protocol.Session
foreach (KeyValuePair<string, SessionToken> item in sessionsTemp)
{
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded", item.Key, item.Value.ID));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loaded, item.Key, item.Value.ID));
sessions[item.Key] = item.Value;
}
}
catch (IOException ex)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.read_fail", ex.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_read_fail, ex.Message));
}
catch (SerializationException ex2)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.malformed", ex2.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_malformed, ex2.Message));
}
}
@ -202,7 +202,7 @@ namespace MinecraftClient.Protocol.Session
if (File.Exists(SessionCacheFilePlaintext))
{
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loading_session", SessionCacheFilePlaintext));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loading_session, SessionCacheFilePlaintext));
try
{
@ -218,25 +218,25 @@ namespace MinecraftClient.Protocol.Session
string login = Settings.ToLowerIfNeed(keyValue[0]);
SessionToken session = SessionToken.FromString(keyValue[1]);
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.loaded", login, session.ID));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_loaded, login, session.ID));
sessions[login] = session;
}
catch (InvalidDataException e)
{
if (Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_string", keyValue[1], e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_string, keyValue[1], e.Message));
}
}
else if (Config.Logging.DebugMessages)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.ignore_line", line));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_ignore_line, line));
}
}
}
}
catch (IOException e)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.read_fail_plain", e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_read_fail_plain, e.Message));
}
}
@ -249,7 +249,7 @@ namespace MinecraftClient.Protocol.Session
private static void SaveToDisk()
{
if (Config.Logging.DebugMessages)
Translations.WriteLineFormatted("cache.saving");
ConsoleIO.WriteLineFormatted(Translations.cache_saving, acceptnewlines: true);
List<string> sessionCacheLines = new()
{
@ -265,7 +265,7 @@ namespace MinecraftClient.Protocol.Session
}
catch (IOException e)
{
ConsoleIO.WriteLineFormatted(Translations.Get("cache.save_fail", e.Message));
ConsoleIO.WriteLineFormatted(string.Format(Translations.cache_save_fail, e.Message));
}
}
}