i18n: help: mark strings for translation
This patch also marks most common commands' synopsis for translation so that "git help" gives a friendly listing. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Apr 23, 2012 at 19:30 UTC
9665627d8cc6f0263f0019e92c67a38223804b57
5 files changed
+47
-38
Makefile
+1
@@ -563,6 +563,7 @@ VCSSVN_H += vcs-svn/svndump.h
563
MISC_H += branch.h
564
MISC_H += bundle.h
565
MISC_H += bisect.h
566
+MISC_H += common-cmds.h
567
MISC_H += fetch-pack.h
568
MISC_H += thread-utils.h
569
MISC_H += send-pack.h
builtin/help.c
+24
-24
@@ -54,7 +54,7 @@ static enum help_format parse_help_format(const char *format)
54
return HELP_FORMAT_INFO;
55
if (!strcmp(format, "web") || !strcmp(format, "html"))
56
return HELP_FORMAT_WEB;
57
- die("unrecognized help format '%s'", format);
57
+ die(_("unrecognized help format '%s'"), format);
58
}
59
60
static const char *get_man_viewer_info(const char *name)
@@ -82,7 +82,7 @@ static int check_emacsclient_version(void)
82
ec_process.err = -1;
83
ec_process.stdout_to_stderr = 1;
84
if (start_command(&ec_process))
85
- return error("Failed to start emacsclient.");
85
+ return error(_("Failed to start emacsclient."));
86
87
strbuf_read(&buffer, ec_process.err, 20);
88
close(ec_process.err);
@@ -95,7 +95,7 @@ static int check_emacsclient_version(void)
95
96
if (prefixcmp(buffer.buf, "emacsclient")) {
97
strbuf_release(&buffer);
98
- return error("Failed to parse emacsclient version.");
98
+ return error(_("Failed to parse emacsclient version."));
99
}
100
101
strbuf_remove(&buffer, 0, strlen("emacsclient"));
@@ -103,7 +103,7 @@ static int check_emacsclient_version(void)
103
104
if (version < 22) {
105
strbuf_release(&buffer);
106
- return error("emacsclient version '%d' too old (< 22).",
106
+ return error(_("emacsclient version '%d' too old (< 22)."),
107
version);
108
}
109
@@ -121,7 +121,7 @@ static void exec_woman_emacs(const char *path, const char *page)
121
path = "emacsclient";
122
strbuf_addf(&man_page, "(woman \"%s\")", page);
123
execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
124
- warning("failed to exec '%s': %s", path, strerror(errno));
124
+ warning(_("failed to exec '%s': %s"), path, strerror(errno));
125
}
126
}
127
@@ -149,7 +149,7 @@ static void exec_man_konqueror(const char *path, const char *page)
149
path = "kfmclient";
150
strbuf_addf(&man_page, "man:%s(1)", page);
151
execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
152
- warning("failed to exec '%s': %s", path, strerror(errno));
152
+ warning(_("failed to exec '%s': %s"), path, strerror(errno));
153
}
154
}
155
@@ -158,7 +158,7 @@ static void exec_man_man(const char *path, const char *page)
158
if (!path)
159
path = "man";
160
execlp(path, "man", page, (char *)NULL);
161
- warning("failed to exec '%s': %s", path, strerror(errno));
161
+ warning(_("failed to exec '%s': %s"), path, strerror(errno));
162
}
163
164
static void exec_man_cmd(const char *cmd, const char *page)
@@ -166,7 +166,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
166
struct strbuf shell_cmd = STRBUF_INIT;
167
strbuf_addf(&shell_cmd, "%s %s", cmd, page);
168
execl("/bin/sh", "sh", "-c", shell_cmd.buf, (char *)NULL);
169
- warning("failed to exec '%s': %s", cmd, strerror(errno));
169
+ warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
170
}
171
172
static void add_man_viewer(const char *name)
@@ -206,8 +206,8 @@ static int add_man_viewer_path(const char *name,
206
if (supported_man_viewer(name, len))
207
do_add_man_viewer_info(name, len, value);
208
else
209
- warning("'%s': path for unsupported man viewer.\n"
210
- "Please consider using 'man.<tool>.cmd' instead.",
209
+ warning(_("'%s': path for unsupported man viewer.\n"
210
+ "Please consider using 'man.<tool>.cmd' instead."),
211
name);
212
213
return 0;
@@ -218,8 +218,8 @@ static int add_man_viewer_cmd(const char *name,
218
const char *value)
219
{
220
if (supported_man_viewer(name, len))
221
- warning("'%s': cmd for supported man viewer.\n"
222
- "Please consider using 'man.<tool>.path' instead.",
221
+ warning(_("'%s': cmd for supported man viewer.\n"
222
+ "Please consider using 'man.<tool>.path' instead."),
223
name);
224
else
225
do_add_man_viewer_info(name, len, value);
@@ -280,11 +280,11 @@ void list_common_cmds_help(void)
280
longest = strlen(common_cmds[i].name);
281
}
282
283
- puts("The most commonly used git commands are:");
283
+ puts(_("The most commonly used git commands are:"));
284
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
285
printf(" %s ", common_cmds[i].name);
286
mput_char(' ', longest - strlen(common_cmds[i].name));
287
- puts(common_cmds[i].help);
287
+ puts(_(common_cmds[i].help));
288
}
289
}
290
@@ -348,7 +348,7 @@ static void exec_viewer(const char *name, const char *page)
348
else if (info)
349
exec_man_cmd(info, page);
350
else
351
- warning("'%s': unknown man viewer.", name);
351
+ warning(_("'%s': unknown man viewer."), name);
352
}
353
354
static void show_man_page(const char *git_cmd)
@@ -365,7 +365,7 @@ static void show_man_page(const char *git_cmd)
365
if (fallback)
366
exec_viewer(fallback, page);
367
exec_viewer("man", page);
368
- die("no man viewer handled the request");
368
+ die(_("no man viewer handled the request"));
369
}
370
371
static void show_info_page(const char *git_cmd)
@@ -373,7 +373,7 @@ static void show_info_page(const char *git_cmd)
373
const char *page = cmd_to_page(git_cmd);
374
setenv("INFOPATH", system_path(GIT_INFO_PATH), 1);
375
execlp("info", "info", "gitman", page, (char *)NULL);
376
- die("no info viewer handled the request");
376
+ die(_("no info viewer handled the request"));
377
}
378
379
static void get_html_page_path(struct strbuf *page_path, const char *page)
@@ -384,7 +384,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
384
/* Check that we have a git documentation directory. */
385
if (stat(mkpath("%s/git.html", html_path), &st)
386
|| !S_ISREG(st.st_mode))
387
- die("'%s': not a documentation directory.", html_path);
387
+ die(_("'%s': not a documentation directory."), html_path);
388
389
strbuf_init(page_path, 0);
390
strbuf_addf(page_path, "%s/%s.html", html_path, page);
@@ -424,16 +424,16 @@ int cmd_help(int argc, const char **argv, const char *prefix)
424
parsed_help_format = help_format;
425
426
if (show_all) {
427
- printf("usage: %s\n\n", git_usage_string);
428
- list_commands("git commands", &main_cmds, &other_cmds);
429
- printf("%s\n", git_more_info_string);
427
+ printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
428
+ list_commands(_("git commands"), &main_cmds, &other_cmds);
429
+ printf("%s\n", _(git_more_info_string));
430
return 0;
431
}
432
433
if (!argv[0]) {
434
- printf("usage: %s\n\n", git_usage_string);
434
+ printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
435
list_common_cmds_help();
436
- printf("\n%s\n", git_more_info_string);
436
+ printf("\n%s\n", _(git_more_info_string));
437
return 0;
438
}
439
@@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
445
446
alias = alias_lookup(argv[0]);
447
if (alias && !is_git_command(argv[0])) {
448
- printf("`git %s' is aliased to `%s'\n", argv[0], alias);
448
+ printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias);
449
return 0;
450
}
451
generate-cmdlist.sh
+1
-1
@@ -16,7 +16,7 @@ do
16
/^NAME/,/git-'"$cmd"'/H
17
${
18
x
19
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
19
+ s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1")},/
20
p
21
}' "Documentation/git-$cmd.txt"
22
done
git.c
+1
-1
@@ -13,7 +13,7 @@ const char git_usage_string[] =
13
" <command> [<args>]";
14
15
const char git_more_info_string[] =
16
- "See 'git help <command>' for more information on a specific command.";
16
+ N_("See 'git help <command>' for more information on a specific command.");
17
18
static struct startup_info git_startup_info;
19
static int use_pager = -1;
help.c
+20
-12
@@ -217,8 +217,9 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
217
218
if (main_cmds->cnt) {
219
const char *exec_path = git_exec_path();
220
- printf("available %s in '%s'\n", title, exec_path);
221
- printf("----------------");
220
+ printf_ln(_("available %s in '%s'"), title, exec_path);
221
+ /* TRANSLATORS: this must align with "available %s in '%s'" */
222
+ printf(_("----------------"));
223
mput_char('-', strlen(title) + strlen(exec_path));
224
putchar('\n');
225
pretty_print_string_list(main_cmds, longest);
@@ -226,8 +227,12 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
227
}
228
229
if (other_cmds->cnt) {
229
- printf("%s available from elsewhere on your $PATH\n", title);
230
- printf("---------------------------------------");
230
+ printf_ln(_("%s available from elsewhere on your $PATH"), title);
231
+ /* TRANSLATORS:
232
+ * this must align with
233
+ * "%s available from elsewhere on your $PATH"
234
+ */
235
+ printf(_("---------------------------------------"));
236
mput_char('-', strlen(title));
237
putchar('\n');
238
pretty_print_string_list(other_cmds, longest);
@@ -341,7 +346,7 @@ const char *help_unknown_cmd(const char *cmd)
346
sizeof(*main_cmds.names), levenshtein_compare);
347
348
if (!main_cmds.cnt)
344
- die ("Uh oh. Your system reports no Git commands at all.");
349
+ die(_("Uh oh. Your system reports no Git commands at all."));
350
351
/* skip and count prefix matches */
352
for (n = 0; n < main_cmds.cnt && !main_cmds.names[n]->len; n++)
@@ -362,23 +367,26 @@ const char *help_unknown_cmd(const char *cmd)
367
const char *assumed = main_cmds.names[0]->name;
368
main_cmds.names[0] = NULL;
369
clean_cmdnames(&main_cmds);
365
- fprintf(stderr, "WARNING: You called a Git command named '%s', "
366
- "which does not exist.\n"
367
- "Continuing under the assumption that you meant '%s'\n",
370
+ fprintf_ln(stderr,
371
+ _("WARNING: You called a Git command named '%s', "
372
+ "which does not exist.\n"
373
+ "Continuing under the assumption that you meant '%s'"),
374
cmd, assumed);
375
if (autocorrect > 0) {
370
- fprintf(stderr, "in %0.1f seconds automatically...\n",
376
+ fprintf_ln(stderr, _("in %0.1f seconds automatically..."),
377
(float)autocorrect/10.0);
378
poll(NULL, 0, autocorrect * 100);
379
}
380
return assumed;
381
}
382
377
- fprintf(stderr, "git: '%s' is not a git command. See 'git --help'.\n", cmd);
383
+ fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);
384
385
if (SIMILAR_ENOUGH(best_similarity)) {
380
- fprintf(stderr, "\nDid you mean %s?\n",
381
- n < 2 ? "this": "one of these");
386
+ fprintf_ln(stderr,
387
+ Q_("\nDid you mean this?",
388
+ "\nDid you mean one of these?",
389
+ n));
390
391
for (i = 0; i < n; i++)
392
fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);