diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3a4552e..6934422 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,8 @@ continuation prompts now follow the session UI language. - The full-screen help title and footer now follow the session UI language, with UTF-8-aware title padding for Chinese. +- Common COMMAND-mode outputs now respect the session language, including + `:users` headers and `:mute-joins` state text. ### Changed - NORMAL mode now opens at the latest visible messages instead of the oldest diff --git a/src/commands.c b/src/commands.c index a218841..9678218 100644 --- a/src/commands.c +++ b/src/commands.c @@ -193,9 +193,15 @@ void commands_dispatch(client_t *client) { strcmp(cmd, "who") == 0) { pthread_rwlock_rdlock(&g_room->lock); int total = g_room->client_count; - buffer_appendf(output, sizeof(output), &pos, - "\033[1;36m在线用户 · online\033[0m " - "\033[2;37m· %d\033[0m\n", total); + if (client->help_lang == LANG_ZH) { + buffer_appendf(output, sizeof(output), &pos, + "\033[1;36m在线用户\033[0m " + "\033[2;37m· %d\033[0m\n", total); + } else { + buffer_appendf(output, sizeof(output), &pos, + "\033[1;36mOnline users\033[0m " + "\033[2;37m· %d\033[0m\n", total); + } time_t now = time(NULL); for (int i = 0; i < total; i++) { @@ -488,9 +494,15 @@ void commands_dispatch(client_t *client) { } else if (strcmp(cmd, "mute-joins") == 0 || strcmp(cmd, "mute") == 0) { client->mute_joins = !client->mute_joins; - buffer_appendf(output, sizeof(output), &pos, - "Join/leave notifications: %s\n", - client->mute_joins ? "muted" : "unmuted"); + if (client->help_lang == LANG_ZH) { + buffer_appendf(output, sizeof(output), &pos, + "加入/离开提示: %s\n", + client->mute_joins ? "已静音" : "已开启"); + } else { + buffer_appendf(output, sizeof(output), &pos, + "Join/leave notifications: %s\n", + client->mute_joins ? "muted" : "unmuted"); + } } else if (strcmp(cmd, "q") == 0 || strcmp(cmd, "quit") == 0 || strcmp(cmd, "exit") == 0) { diff --git a/tests/test_interactive_input.sh b/tests/test_interactive_input.sh index 81b42de..fa0472c 100755 --- a/tests/test_interactive_input.sh +++ b/tests/test_interactive_input.sh @@ -204,6 +204,53 @@ else FAIL=$((FAIL + 1)) fi +LOCALIZED_COMMANDS_SCRIPT="$STATE_DIR/localized-commands.expect" +cat >"$LOCALIZED_COMMANDS_SCRIPT" <"$STATE_DIR/localized-commands.log" 2>&1; then + echo "✓ common command output follows session language" + PASS=$((PASS + 1)) +else + echo "x localized command output failed" + sed -n '1,200p' "$STATE_DIR/localized-commands.log" + sed -n '1,120p' "$STATE_DIR/server.log" + FAIL=$((FAIL + 1)) +fi + echo "" echo "PASSED: $PASS" echo "FAILED: $FAIL"