mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 05:34:39 +08:00
i18n: localize help screen chrome
This commit is contained in:
parent
f535b928d1
commit
92123d208d
5 changed files with 21 additions and 4 deletions
|
|
@ -10,6 +10,8 @@
|
|||
their current session.
|
||||
- COMMAND-mode `:help`, unknown-command guidance, language command output, and
|
||||
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.
|
||||
|
||||
### Changed
|
||||
- NORMAL mode now opens at the latest visible messages instead of the oldest
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ typedef enum {
|
|||
I18N_INSERT_HINT_WIDE,
|
||||
I18N_INSERT_HINT_NARROW,
|
||||
I18N_NORMAL_LATEST,
|
||||
I18N_NORMAL_NEW_MESSAGES
|
||||
I18N_NORMAL_NEW_MESSAGES,
|
||||
I18N_HELP_TITLE,
|
||||
I18N_HELP_STATUS_FORMAT
|
||||
} i18n_text_id_t;
|
||||
|
||||
bool i18n_try_parse_lang(const char *value, help_lang_t *lang);
|
||||
|
|
|
|||
|
|
@ -85,6 +85,10 @@ const char *i18n_text(help_lang_t lang, i18n_text_id_t id) {
|
|||
return "G 最新";
|
||||
case I18N_NORMAL_NEW_MESSAGES:
|
||||
return "新消息";
|
||||
case I18N_HELP_TITLE:
|
||||
return " 帮助 ";
|
||||
case I18N_HELP_STATUS_FORMAT:
|
||||
return "-- 帮助 -- (%d/%d) j/k:滚动 g/G:首尾 e/z:语言 q:关闭";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +107,10 @@ const char *i18n_text(help_lang_t lang, i18n_text_id_t id) {
|
|||
return "G latest";
|
||||
case I18N_NORMAL_NEW_MESSAGES:
|
||||
return "new";
|
||||
case I18N_HELP_TITLE:
|
||||
return " HELP ";
|
||||
case I18N_HELP_STATUS_FORMAT:
|
||||
return "-- HELP -- (%d/%d) j/k:scroll g/G:top/bottom e/z:lang q:close";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "ssh_server.h"
|
||||
#include "chat_room.h"
|
||||
#include "history_view.h"
|
||||
#include "i18n.h"
|
||||
#include "tui_status.h"
|
||||
#include "utf8.h"
|
||||
#include <unistd.h>
|
||||
|
|
@ -875,8 +876,8 @@ void tui_render_help(client_t *client) {
|
|||
buffer_appendf(buffer, sizeof(buffer), &pos, ANSI_CLEAR ANSI_HOME);
|
||||
|
||||
/* Title */
|
||||
const char *title = " HELP ";
|
||||
int title_width = strlen(title);
|
||||
const char *title = i18n_text(client->help_lang, I18N_HELP_TITLE);
|
||||
int title_width = utf8_string_width(title);
|
||||
int padding = rw - title_width;
|
||||
if (padding < 0) padding = 0;
|
||||
|
||||
|
|
@ -921,7 +922,7 @@ void tui_render_help(client_t *client) {
|
|||
|
||||
/* Status line */
|
||||
buffer_appendf(buffer, sizeof(buffer), &pos,
|
||||
"-- HELP -- (%d/%d) j/k:scroll g/G:top/bottom e/z:lang q:close",
|
||||
i18n_text(client->help_lang, I18N_HELP_STATUS_FORMAT),
|
||||
start + 1, max_scroll + 1);
|
||||
|
||||
client_send(client, buffer, pos);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,10 @@ TEST(text_lookup_matches_language) {
|
|||
"display name") != NULL);
|
||||
assert(strstr(i18n_text(LANG_ZH, I18N_USERNAME_PROMPT),
|
||||
"用户名") != NULL);
|
||||
assert(strstr(i18n_text(LANG_EN, I18N_HELP_STATUS_FORMAT),
|
||||
"HELP") != NULL);
|
||||
assert(strstr(i18n_text(LANG_ZH, I18N_HELP_STATUS_FORMAT),
|
||||
"帮助") != NULL);
|
||||
assert(strcmp(i18n_lang_code(LANG_EN), "en") == 0);
|
||||
assert(strcmp(i18n_lang_code(LANG_ZH), "zh") == 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue