diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c13ca6a..de6a012 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -38,6 +38,7 @@ command output. - Startup CLI help and option errors now live in a dedicated `cli_text` module and follow `TNT_LANG` / locale for English and Chinese users. +- Idle-timeout disconnect notices now follow the session UI language. ### Changed - NORMAL mode now opens at the latest visible messages instead of the oldest diff --git a/include/i18n.h b/include/i18n.h index c7f1193..0021ea0 100644 --- a/include/i18n.h +++ b/include/i18n.h @@ -22,6 +22,7 @@ typedef enum { I18N_TITLE_ONLINE_FORMAT, I18N_TITLE_MUTED, I18N_TITLE_HELP_HINT, + I18N_IDLE_TIMEOUT_FORMAT, I18N_SYSTEM_USERNAME, I18N_SYSTEM_JOIN_FORMAT, I18N_SYSTEM_LEAVE_FORMAT, diff --git a/src/i18n.c b/src/i18n.c index 90a333c..c721a51 100644 --- a/src/i18n.c +++ b/src/i18n.c @@ -107,6 +107,8 @@ const char *i18n_text(help_lang_t lang, i18n_text_id_t id) { return "静音"; case I18N_TITLE_HELP_HINT: return "? 帮助"; + case I18N_IDLE_TIMEOUT_FORMAT: + return "\r\n\033[33m已断开: 空闲超时 (%d 分钟)\033[0m\r\n"; case I18N_SYSTEM_USERNAME: return "系统"; case I18N_SYSTEM_JOIN_FORMAT: @@ -237,6 +239,8 @@ const char *i18n_text(help_lang_t lang, i18n_text_id_t id) { return "muted"; case I18N_TITLE_HELP_HINT: return "? help"; + case I18N_IDLE_TIMEOUT_FORMAT: + return "\r\n\033[33mDisconnected: idle timeout (%d min)\033[0m\r\n"; case I18N_SYSTEM_USERNAME: return "system"; case I18N_SYSTEM_JOIN_FORMAT: diff --git a/src/input.c b/src/input.c index 441db18..458dfe0 100644 --- a/src/input.c +++ b/src/input.c @@ -787,7 +787,9 @@ main_loop: if (g_idle_timeout > 0 && joined_room && time(NULL) - client->last_active >= g_idle_timeout) { - client_printf(client, "\r\n\033[33mDisconnected: idle timeout (%d min)\033[0m\r\n", + client_printf(client, + i18n_text(client->help_lang, + I18N_IDLE_TIMEOUT_FORMAT), g_idle_timeout / 60); break; } diff --git a/tests/unit/test_i18n.c b/tests/unit/test_i18n.c index ea587f6..ef98c60 100644 --- a/tests/unit/test_i18n.c +++ b/tests/unit/test_i18n.c @@ -82,6 +82,10 @@ TEST(text_lookup_matches_language) { "online") != NULL); assert(strstr(i18n_text(LANG_ZH, I18N_TITLE_ONLINE_FORMAT), "在线") != NULL); + assert(strstr(i18n_text(LANG_EN, I18N_IDLE_TIMEOUT_FORMAT), + "idle timeout") != NULL); + assert(strstr(i18n_text(LANG_ZH, I18N_IDLE_TIMEOUT_FORMAT), + "空闲超时") != NULL); assert(strstr(i18n_text(LANG_EN, I18N_MSG_USAGE), "msg ") != NULL); assert(strstr(i18n_text(LANG_ZH, I18N_MSG_USAGE),