mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 05:44:38 +08:00
exec: use localized strings for catalog chrome
This commit is contained in:
parent
6c8ea56e8d
commit
cd49519058
3 changed files with 16 additions and 11 deletions
|
|
@ -64,6 +64,8 @@
|
|||
around the command-catalog rows.
|
||||
- The full-screen key reference now uses the shared localized-string helper
|
||||
around the command-catalog rows.
|
||||
- SSH exec help headers and usage prefixes now use the shared
|
||||
localized-string helper and English fallback path.
|
||||
- Documented i18n and user-facing text rules for English-first source text,
|
||||
stable command syntax, concise help copy, and translation-only localization.
|
||||
|
||||
|
|
|
|||
|
|
@ -134,11 +134,11 @@ bool exec_catalog_args_valid(tnt_exec_command_id_t id, const char *args) {
|
|||
|
||||
void exec_catalog_append_help(char *buffer, size_t buf_size, size_t *pos,
|
||||
ui_lang_t lang) {
|
||||
if (lang == UI_LANG_ZH) {
|
||||
buffer_appendf(buffer, buf_size, pos, "TNT exec 接口\n命令:\n");
|
||||
} else {
|
||||
buffer_appendf(buffer, buf_size, pos, "TNT exec interface\nCommands:\n");
|
||||
}
|
||||
static const i18n_string_t header =
|
||||
I18N_STRING("TNT exec interface\nCommands:\n",
|
||||
"TNT exec 接口\n命令:\n");
|
||||
|
||||
buffer_appendf(buffer, buf_size, pos, "%s", i18n_string(header, lang));
|
||||
|
||||
for (size_t i = 0; i < sizeof(entries) / sizeof(entries[0]); i++) {
|
||||
const char *summary = i18n_string(entries[i].summary, lang);
|
||||
|
|
@ -150,15 +150,12 @@ void exec_catalog_append_help(char *buffer, size_t buf_size, size_t *pos,
|
|||
void exec_catalog_append_usage(char *buffer, size_t buf_size, size_t *pos,
|
||||
tnt_exec_command_id_t id, ui_lang_t lang) {
|
||||
const exec_catalog_entry_t *entry = entry_for_id(id);
|
||||
static const i18n_string_t usage_format =
|
||||
I18N_STRING("%s: usage: %s\n", "%s: 用法: %s\n");
|
||||
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
if (lang == UI_LANG_ZH) {
|
||||
buffer_appendf(buffer, buf_size, pos, "%s: 用法: %s\n",
|
||||
entry->name, entry->usage_syntax);
|
||||
return;
|
||||
}
|
||||
buffer_appendf(buffer, buf_size, pos, "%s: usage: %s\n",
|
||||
buffer_appendf(buffer, buf_size, pos, i18n_string(usage_format, lang),
|
||||
entry->name, entry->usage_syntax);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,12 @@ TEST(generates_localized_usage) {
|
|||
|
||||
assert(strcmp(en, "tail: usage: tail [N] | tail -n N\n") == 0);
|
||||
assert(strcmp(zh, "post: 用法: post MESSAGE\n") == 0);
|
||||
|
||||
memset(en, 0, sizeof(en));
|
||||
en_pos = 0;
|
||||
exec_catalog_append_usage(en, sizeof(en), &en_pos,
|
||||
TNT_EXEC_COMMAND_TAIL, (ui_lang_t)99);
|
||||
assert(strcmp(en, "tail: usage: tail [N] | tail -n N\n") == 0);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue