mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 09:14:38 +08:00
i18n: localize title bar status
This commit is contained in:
parent
aca68824ac
commit
1d8fcea3fa
6 changed files with 30 additions and 4 deletions
|
|
@ -20,6 +20,8 @@
|
|||
unknown-command guidance.
|
||||
- Command output text for common interactive commands is now centralized in
|
||||
the i18n table instead of being scattered through command flow logic.
|
||||
- TUI title-bar status labels, including online count, mute marker, and help
|
||||
hint, now follow the session UI language.
|
||||
|
||||
### Changed
|
||||
- NORMAL mode now opens at the latest visible messages instead of the oldest
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ typedef enum {
|
|||
I18N_COMMAND_OUTPUT_TITLE,
|
||||
I18N_MOTD_TITLE,
|
||||
I18N_MOTD_CONTINUE_HINT,
|
||||
I18N_TITLE_ONLINE_FORMAT,
|
||||
I18N_TITLE_MUTED,
|
||||
I18N_TITLE_HELP_HINT,
|
||||
I18N_USERS_TITLE,
|
||||
I18N_MSG_USAGE,
|
||||
I18N_MSG_SENT_FORMAT,
|
||||
|
|
|
|||
12
src/i18n.c
12
src/i18n.c
|
|
@ -95,6 +95,12 @@ const char *i18n_text(help_lang_t lang, i18n_text_id_t id) {
|
|||
return " 公告 ";
|
||||
case I18N_MOTD_CONTINUE_HINT:
|
||||
return " 按任意键继续 ";
|
||||
case I18N_TITLE_ONLINE_FORMAT:
|
||||
return "在线 %d";
|
||||
case I18N_TITLE_MUTED:
|
||||
return "静音";
|
||||
case I18N_TITLE_HELP_HINT:
|
||||
return "? 帮助";
|
||||
case I18N_USERS_TITLE:
|
||||
return "在线用户";
|
||||
case I18N_MSG_USAGE:
|
||||
|
|
@ -162,6 +168,12 @@ const char *i18n_text(help_lang_t lang, i18n_text_id_t id) {
|
|||
return " NOTICE ";
|
||||
case I18N_MOTD_CONTINUE_HINT:
|
||||
return " Press any key ";
|
||||
case I18N_TITLE_ONLINE_FORMAT:
|
||||
return "online %d";
|
||||
case I18N_TITLE_MUTED:
|
||||
return "muted";
|
||||
case I18N_TITLE_HELP_HINT:
|
||||
return "? help";
|
||||
case I18N_USERS_TITLE:
|
||||
return "Online users";
|
||||
case I18N_MSG_USAGE:
|
||||
|
|
|
|||
12
src/tui.c
12
src/tui.c
|
|
@ -356,7 +356,9 @@ void tui_render_screen(client_t *client) {
|
|||
chip_count++;
|
||||
|
||||
char online_buf[32];
|
||||
snprintf(online_buf, sizeof(online_buf), "在线 %d", online);
|
||||
snprintf(online_buf, sizeof(online_buf),
|
||||
i18n_text(client->help_lang, I18N_TITLE_ONLINE_FORMAT),
|
||||
online);
|
||||
chips[chip_count].value = online_buf;
|
||||
chips[chip_count].value_color = "\033[37m";
|
||||
chip_count++;
|
||||
|
|
@ -373,9 +375,10 @@ void tui_render_screen(client_t *client) {
|
|||
chips[chip_count].value_color = mode_color;
|
||||
chip_count++;
|
||||
|
||||
const char *hint = "? 帮助";
|
||||
const char *hint = i18n_text(client->help_lang, I18N_TITLE_HELP_HINT);
|
||||
int hint_width = utf8_string_width(hint);
|
||||
int mute_width = client->mute_joins ? 6 : 0; /* " 静音" = 2 + 4 */
|
||||
const char *mute_label = i18n_text(client->help_lang, I18N_TITLE_MUTED);
|
||||
int mute_width = client->mute_joins ? utf8_string_width(mute_label) + 2 : 0;
|
||||
|
||||
/* Unread @-mentions chip — high-priority, gets a bright yellow star.
|
||||
* Sits between mode and hint when present, and survives degradation
|
||||
|
|
@ -442,7 +445,8 @@ void tui_render_screen(client_t *client) {
|
|||
left_width += utf8_string_width(chips[i].value);
|
||||
}
|
||||
if (show_mute) {
|
||||
buffer_appendf(left, sizeof(left), &lpos, " \033[2;37m静音\033[0m");
|
||||
buffer_appendf(left, sizeof(left), &lpos,
|
||||
" \033[2;37m%s\033[0m", mute_label);
|
||||
left_width += mute_width;
|
||||
}
|
||||
if (show_unread) {
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ expect "Language set to: en"
|
|||
expect "Press any key"
|
||||
send -- "q"
|
||||
expect "NORMAL"
|
||||
expect "online"
|
||||
send -- ":"
|
||||
expect ":"
|
||||
send -- "users\r"
|
||||
|
|
|
|||
|
|
@ -74,6 +74,10 @@ TEST(text_lookup_matches_language) {
|
|||
"Press any key") != NULL);
|
||||
assert(strstr(i18n_text(LANG_ZH, I18N_MOTD_CONTINUE_HINT),
|
||||
"按任意键") != NULL);
|
||||
assert(strstr(i18n_text(LANG_EN, I18N_TITLE_ONLINE_FORMAT),
|
||||
"online") != NULL);
|
||||
assert(strstr(i18n_text(LANG_ZH, I18N_TITLE_ONLINE_FORMAT),
|
||||
"在线") != NULL);
|
||||
assert(strstr(i18n_text(LANG_EN, I18N_MSG_USAGE),
|
||||
"msg <username>") != NULL);
|
||||
assert(strstr(i18n_text(LANG_ZH, I18N_MSG_USAGE),
|
||||
|
|
|
|||
Loading…
Reference in a new issue