From 934bf2cda1351535b3e0781b68059bc02ab6c61a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 2 Jul 2015 00:29:02 +0200 Subject: [PATCH] (command.c) Translatable strings --- command.c | 20 +++++++++++++------- intl/msg_hash_us.c | 6 ++++++ msg_hash.h | 7 +++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/command.c b/command.c index 61ade1a973..6cbe48a94f 100644 --- a/command.c +++ b/command.c @@ -27,10 +27,10 @@ #include #include #include -#include - #include +#include "msg_hash.h" + #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) #include "netplay.h" #endif @@ -230,7 +230,7 @@ static bool cmd_set_shader(const char *arg) char msg[PATH_MAX_LENGTH] = {0}; enum rarch_shader_type type = RARCH_SHADER_NONE; const char *ext = path_get_extension(arg); - uint32_t ext_hash = djb2_calculate(ext); + uint32_t ext_hash = msg_hash_calculate(ext); switch (ext_hash) { @@ -248,7 +248,9 @@ static bool cmd_set_shader(const char *arg) snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg); rarch_main_msg_queue_push(msg, 1, 120, true); - RARCH_LOG("Applying shader \"%s\".\n", arg); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_APPLYING_SHADER), + arg); return video_driver_set_shader(type, arg); } @@ -314,7 +316,10 @@ static void parse_sub_msg(rarch_cmd_t *handle, const char *tok) handle->state[map[index].id] = true; } else - RARCH_WARN("Unrecognized command \"%s\" received.\n", tok); + RARCH_WARN("%s \"%s\" %s.\n", + msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), + tok, + msg_hash_to_str(MSG_RECEIVED)); } static void parse_msg(rarch_cmd_t *handle, char *buf) @@ -619,7 +624,7 @@ bool network_cmd_send(const char *cmd_) const char *host = NULL; const char *port_ = NULL; global_t *global = global_get_ptr(); - bool old_verbose = global->verbosity; + bool old_verbose = global ? global->verbosity : false; uint16_t port = DEFAULT_NETWORK_CMD_PORT; if (!network_init()) @@ -648,7 +653,8 @@ bool network_cmd_send(const char *cmd_) if (port_) port = strtoul(port_, NULL, 0); - RARCH_LOG("Sending command: \"%s\" to %s:%hu\n", + RARCH_LOG("%s: \"%s\" to %s:%hu\n", + msg_hash_to_str(MSG_SENDING_COMMAND), cmd, host, (unsigned short)port); ret = verify_command(cmd) && send_udp_packet(host, port, cmd); diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index ad0619c826..b825b82759 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -20,6 +20,12 @@ const char *msg_hash_to_str_us(uint32_t hash) { switch (hash) { + case MSG_RECEIVED: + return "received"; + case MSG_UNRECOGNIZED_COMMAND: + return "Unrecognized command"; + case MSG_SENDING_COMMAND: + return "Sending command"; case MSG_GOT_INVALID_DISK_INDEX: return "Got invalid disk index."; case MSG_FAILED_TO_REMOVE_DISK_FROM_TRAY: diff --git a/msg_hash.h b/msg_hash.h index 4abeef65d6..78e356b6e7 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -21,6 +21,13 @@ #include #include + +#define MSG_RECEIVED 0xfe0c06acU + +#define MSG_UNRECOGNIZED_COMMAND 0x946b8a50U + +#define MSG_SENDING_COMMAND 0x562cf28bU + #define MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT 0x5aa753b8U #define MSG_REWINDING 0xccbeec2cU