Skip to content

Commit 7a76c28

Browse files
moygitster
authored andcommitted
status: disable translation when --porcelain is used
"git status --branch --porcelain" displays the status of the branch (ahead, behind, gone), and used gettext to translate the string. Use hardcoded strings when --porcelain is used, but keep the gettext translation for "git status --short" which is essentially the same, but meant to be read by a human. Reported-by: Anarky <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bbc4e8 commit 7a76c28

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

wt-status.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,19 +1483,21 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
14831483
return;
14841484
}
14851485

1486+
#define LABEL(string) (s->no_gettext ? (string) : _(string))
1487+
14861488
color_fprintf(s->fp, header_color, " [");
14871489
if (upstream_is_gone) {
1488-
color_fprintf(s->fp, header_color, _("gone"));
1490+
color_fprintf(s->fp, header_color, LABEL(N_("gone")));
14891491
} else if (!num_ours) {
1490-
color_fprintf(s->fp, header_color, _("behind "));
1492+
color_fprintf(s->fp, header_color, LABEL(N_("behind ")));
14911493
color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
14921494
} else if (!num_theirs) {
1493-
color_fprintf(s->fp, header_color, _("ahead "));
1495+
color_fprintf(s->fp, header_color, LABEL(N_(("ahead "))));
14941496
color_fprintf(s->fp, branch_color_local, "%d", num_ours);
14951497
} else {
1496-
color_fprintf(s->fp, header_color, _("ahead "));
1498+
color_fprintf(s->fp, header_color, LABEL(N_(("ahead "))));
14971499
color_fprintf(s->fp, branch_color_local, "%d", num_ours);
1498-
color_fprintf(s->fp, header_color, _(", behind "));
1500+
color_fprintf(s->fp, header_color, ", %s", LABEL(N_("behind ")));
14991501
color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
15001502
}
15011503

@@ -1540,5 +1542,6 @@ void wt_porcelain_print(struct wt_status *s)
15401542
s->use_color = 0;
15411543
s->relative_paths = 0;
15421544
s->prefix = NULL;
1545+
s->no_gettext = 1;
15431546
wt_shortstatus_print(s);
15441547
}

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct wt_status {
5050
enum commit_whence whence;
5151
int nowarn;
5252
int use_color;
53+
int no_gettext;
5354
int display_comment_prefix;
5455
int relative_paths;
5556
int submodule_summary;

0 commit comments

Comments
 (0)