Translate access denied strings (#14842)

This commit is contained in:
1F616EMO~nya 2024-08-18 01:48:54 +08:00 committed by GitHub
parent 1fb49e9ca7
commit 5acc2736db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 19 deletions

@ -48,6 +48,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "particles.h" #include "particles.h"
#include <memory> #include <memory>
const char *accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
N_("Invalid password"),
N_("Your client sent something the server didn't expect. Try reconnecting or updating your client."),
N_("The server is running in singleplayer mode. You cannot connect."),
N_("Your client's version is not supported.\nPlease contact the server administrator."),
N_("Player name contains disallowed characters"),
N_("Player name not allowed"),
N_("Too many users"),
N_("Empty passwords are disallowed. Set a password and try again."),
N_("Another client is connected with this name. If your client closed unexpectedly, try again in a minute."),
N_("Internal server error"),
"",
N_("Server shutting down"),
N_("The server has experienced an internal error. You will now be disconnected.")
};
void Client::handleCommand_Deprecated(NetworkPacket* pkt) void Client::handleCommand_Deprecated(NetworkPacket* pkt)
{ {
infostream << "Got deprecated command " infostream << "Got deprecated command "
@ -216,17 +232,17 @@ void Client::handleCommand_AccessDenied(NetworkPacket* pkt)
denyCode == SERVER_ACCESSDENIED_CRASH) { denyCode == SERVER_ACCESSDENIED_CRASH) {
*pkt >> m_access_denied_reason; *pkt >> m_access_denied_reason;
if (m_access_denied_reason.empty()) if (m_access_denied_reason.empty())
m_access_denied_reason = accessDeniedStrings[denyCode]; m_access_denied_reason = gettext(accessDeniedStrings[denyCode]);
u8 reconnect; u8 reconnect;
*pkt >> reconnect; *pkt >> reconnect;
m_access_denied_reconnect = reconnect & 1; m_access_denied_reconnect = reconnect & 1;
} else if (denyCode == SERVER_ACCESSDENIED_CUSTOM_STRING) { } else if (denyCode == SERVER_ACCESSDENIED_CUSTOM_STRING) {
*pkt >> m_access_denied_reason; *pkt >> m_access_denied_reason;
} else if (denyCode == SERVER_ACCESSDENIED_TOO_MANY_USERS) { } else if (denyCode == SERVER_ACCESSDENIED_TOO_MANY_USERS) {
m_access_denied_reason = accessDeniedStrings[denyCode]; m_access_denied_reason = gettext(accessDeniedStrings[denyCode]);
m_access_denied_reconnect = true; m_access_denied_reconnect = true;
} else if (denyCode < SERVER_ACCESSDENIED_MAX) { } else if (denyCode < SERVER_ACCESSDENIED_MAX) {
m_access_denied_reason = accessDeniedStrings[denyCode]; m_access_denied_reason = gettext(accessDeniedStrings[denyCode]);
} else { } else {
// Allow us to add new error messages to the // Allow us to add new error messages to the
// protocol without raising the protocol version, if we want to. // protocol without raising the protocol version, if we want to.

@ -1150,22 +1150,6 @@ enum NetProtoCompressionMode {
NETPROTO_COMPRESSION_NONE = 0, NETPROTO_COMPRESSION_NONE = 0,
}; };
constexpr const char *accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
"Invalid password",
"Your client sent something the server didn't expect. Try reconnecting or updating your client.",
"The server is running in simple singleplayer mode. You cannot connect.",
"Your client's version is not supported.\nPlease contact the server administrator.",
"Player name contains disallowed characters",
"Player name not allowed",
"Too many users",
"Empty passwords are disallowed. Set a password and try again.",
"Another client is connected with this name. If your client closed unexpectedly, try again in a minute.",
"Internal server error",
"",
"Server shutting down",
"The server has experienced an internal error. You will now be disconnected."
};
enum PlayerListModifer : u8 enum PlayerListModifer : u8
{ {
PLAYER_LIST_INIT, PLAYER_LIST_INIT,