mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 21:44:39 +08:00
i18n: localize common command outputs
This commit is contained in:
parent
92123d208d
commit
22ab85acef
3 changed files with 67 additions and 6 deletions
|
|
@ -12,6 +12,8 @@
|
||||||
continuation prompts now follow the session UI language.
|
continuation prompts now follow the session UI language.
|
||||||
- The full-screen help title and footer 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.
|
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
|
### Changed
|
||||||
- NORMAL mode now opens at the latest visible messages instead of the oldest
|
- NORMAL mode now opens at the latest visible messages instead of the oldest
|
||||||
|
|
|
||||||
|
|
@ -193,9 +193,15 @@ void commands_dispatch(client_t *client) {
|
||||||
strcmp(cmd, "who") == 0) {
|
strcmp(cmd, "who") == 0) {
|
||||||
pthread_rwlock_rdlock(&g_room->lock);
|
pthread_rwlock_rdlock(&g_room->lock);
|
||||||
int total = g_room->client_count;
|
int total = g_room->client_count;
|
||||||
buffer_appendf(output, sizeof(output), &pos,
|
if (client->help_lang == LANG_ZH) {
|
||||||
"\033[1;36m在线用户 · online\033[0m "
|
buffer_appendf(output, sizeof(output), &pos,
|
||||||
"\033[2;37m· %d\033[0m\n", total);
|
"\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);
|
time_t now = time(NULL);
|
||||||
for (int i = 0; i < total; i++) {
|
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) {
|
} else if (strcmp(cmd, "mute-joins") == 0 || strcmp(cmd, "mute") == 0) {
|
||||||
client->mute_joins = !client->mute_joins;
|
client->mute_joins = !client->mute_joins;
|
||||||
buffer_appendf(output, sizeof(output), &pos,
|
if (client->help_lang == LANG_ZH) {
|
||||||
"Join/leave notifications: %s\n",
|
buffer_appendf(output, sizeof(output), &pos,
|
||||||
client->mute_joins ? "muted" : "unmuted");
|
"加入/离开提示: %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 ||
|
} else if (strcmp(cmd, "q") == 0 || strcmp(cmd, "quit") == 0 ||
|
||||||
strcmp(cmd, "exit") == 0) {
|
strcmp(cmd, "exit") == 0) {
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,53 @@ else
|
||||||
FAIL=$((FAIL + 1))
|
FAIL=$((FAIL + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LOCALIZED_COMMANDS_SCRIPT="$STATE_DIR/localized-commands.expect"
|
||||||
|
cat >"$LOCALIZED_COMMANDS_SCRIPT" <<EOF
|
||||||
|
set timeout 10
|
||||||
|
spawn ssh $SSH_OPTS anonymous@127.0.0.1
|
||||||
|
sleep 1
|
||||||
|
send -- "localized\r"
|
||||||
|
expect ":support"
|
||||||
|
send -- "\033"
|
||||||
|
expect "NORMAL"
|
||||||
|
send -- ":"
|
||||||
|
expect ":"
|
||||||
|
send -- "mute-joins\r"
|
||||||
|
expect "加入/离开提示"
|
||||||
|
expect "已静音"
|
||||||
|
expect "按任意键"
|
||||||
|
send -- "q"
|
||||||
|
expect "NORMAL"
|
||||||
|
send -- ":"
|
||||||
|
expect ":"
|
||||||
|
send -- "lang en\r"
|
||||||
|
expect "Language set to: en"
|
||||||
|
expect "Press any key"
|
||||||
|
send -- "q"
|
||||||
|
expect "NORMAL"
|
||||||
|
send -- ":"
|
||||||
|
expect ":"
|
||||||
|
send -- "users\r"
|
||||||
|
expect "Online users"
|
||||||
|
expect "Press any key"
|
||||||
|
send -- "q"
|
||||||
|
sleep 0.2
|
||||||
|
send -- "\003"
|
||||||
|
sleep 0.2
|
||||||
|
send -- "\003"
|
||||||
|
expect eof
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if expect "$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 ""
|
||||||
echo "PASSED: $PASS"
|
echo "PASSED: $PASS"
|
||||||
echo "FAILED: $FAIL"
|
echo "FAILED: $FAIL"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue