Skip to content

Commit 82348e8

Browse files
committed
fast-export: mark strings for translation
Some error or warning messages in "builtin/fast-export.c" are marked for translation, but many are not. To be more consistent and provide a better experience to people using a translated version, let's mark all the remaining error or warning messages for translation. While at it: - improve how some arguments to some error functions are indented, - remove "Error:" at the start of an error message, - downcase error and warning messages that start with an uppercase. Signed-off-by: Christian Couder <[email protected]>
1 parent e653da1 commit 82348e8

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

builtin/fast-export.c

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int parse_opt_sign_mode(const struct option *opt,
6565
return 0;
6666

6767
if (parse_sign_mode(arg, val))
68-
return error("Unknown %s mode: %s", opt->long_name, arg);
68+
return error(_("unknown %s mode: %s"), opt->long_name, arg);
6969

7070
return 0;
7171
}
@@ -82,7 +82,7 @@ static int parse_opt_tag_of_filtered_mode(const struct option *opt,
8282
else if (!strcmp(arg, "rewrite"))
8383
*val = REWRITE;
8484
else
85-
return error("Unknown tag-of-filtered mode: %s", arg);
85+
return error(_("unknown tag-of-filtered mode: %s"), arg);
8686
return 0;
8787
}
8888

@@ -107,7 +107,7 @@ static int parse_opt_reencode_mode(const struct option *opt,
107107
if (!strcasecmp(arg, "abort"))
108108
*val = REENCODE_ABORT;
109109
else
110-
return error("Unknown reencoding mode: %s", arg);
110+
return error(_("unknown reencoding mode: %s"), arg);
111111
}
112112

113113
return 0;
@@ -318,16 +318,16 @@ static void export_blob(const struct object_id *oid)
318318
} else {
319319
buf = odb_read_object(the_repository->objects, oid, &type, &size);
320320
if (!buf)
321-
die("could not read blob %s", oid_to_hex(oid));
321+
die(_("could not read blob %s"), oid_to_hex(oid));
322322
if (check_object_signature(the_repository, oid, buf, size,
323323
type) < 0)
324-
die("oid mismatch in blob %s", oid_to_hex(oid));
324+
die(_("oid mismatch in blob %s"), oid_to_hex(oid));
325325
object = parse_object_buffer(the_repository, oid, type,
326326
size, buf, &eaten);
327327
}
328328

329329
if (!object)
330-
die("Could not read blob %s", oid_to_hex(oid));
330+
die(_("could not read blob %s"), oid_to_hex(oid));
331331

332332
mark_next_object(object);
333333

@@ -336,7 +336,7 @@ static void export_blob(const struct object_id *oid)
336336
printf("original-oid %s\n", oid_to_hex(oid));
337337
printf("data %"PRIuMAX"\n", (uintmax_t)size);
338338
if (size && fwrite(buf, size, 1, stdout) != 1)
339-
die_errno("could not write blob '%s'", oid_to_hex(oid));
339+
die_errno(_("could not write blob '%s'"), oid_to_hex(oid));
340340
printf("\n");
341341

342342
show_progress();
@@ -499,10 +499,10 @@ static void show_filemodify(struct diff_queue_struct *q,
499499
break;
500500

501501
default:
502-
die("Unexpected comparison status '%c' for %s, %s",
503-
q->queue[i]->status,
504-
ospec->path ? ospec->path : "none",
505-
spec->path ? spec->path : "none");
502+
die(_("unexpected comparison status '%c' for %s, %s"),
503+
q->queue[i]->status,
504+
ospec->path ? ospec->path : _("none"),
505+
spec->path ? spec->path : _("none"));
506506
}
507507
}
508508
}
@@ -699,14 +699,14 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
699699

700700
author = strstr(commit_buffer_cursor, "\nauthor ");
701701
if (!author)
702-
die("could not find author in commit %s",
702+
die(_("could not find author in commit %s"),
703703
oid_to_hex(&commit->object.oid));
704704
author++;
705705
commit_buffer_cursor = author_end = strchrnul(author, '\n');
706706

707707
committer = strstr(commit_buffer_cursor, "\ncommitter ");
708708
if (!committer)
709-
die("could not find committer in commit %s",
709+
die(_("could not find committer in commit %s"),
710710
oid_to_hex(&commit->object.oid));
711711
committer++;
712712
commit_buffer_cursor = committer_end = strchrnul(committer, '\n');
@@ -781,8 +781,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
781781
case REENCODE_NO:
782782
break;
783783
case REENCODE_ABORT:
784-
die("Encountered commit-specific encoding %.*s in commit "
785-
"%s; use --reencode=[yes|no] to handle it",
784+
die(_("encountered commit-specific encoding %.*s in commit "
785+
"%s; use --reencode=[yes|no] to handle it"),
786786
(int)encoding_len, encoding,
787787
oid_to_hex(&commit->object.oid));
788788
}
@@ -798,11 +798,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
798798
if (signatures.nr) {
799799
switch (signed_commit_mode) {
800800
case SIGN_ABORT:
801-
die("encountered signed commit %s; use "
802-
"--signed-commits=<mode> to handle it",
801+
die(_("encountered signed commit %s; use "
802+
"--signed-commits=<mode> to handle it"),
803803
oid_to_hex(&commit->object.oid));
804804
case SIGN_WARN_VERBATIM:
805-
warning("exporting %"PRIuMAX" signature(s) for commit %s",
805+
warning(_("exporting %"PRIuMAX" signature(s) for commit %s"),
806806
(uintmax_t)signatures.nr, oid_to_hex(&commit->object.oid));
807807
/* fallthru */
808808
case SIGN_VERBATIM:
@@ -812,7 +812,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
812812
}
813813
break;
814814
case SIGN_WARN_STRIP:
815-
warning("stripping signature(s) from commit %s",
815+
warning(_("stripping signature(s) from commit %s"),
816816
oid_to_hex(&commit->object.oid));
817817
/* fallthru */
818818
case SIGN_STRIP:
@@ -890,15 +890,16 @@ static void handle_tag(const char *name, struct tag *tag)
890890
tagged = ((struct tag *)tagged)->tagged;
891891
}
892892
if (tagged->type == OBJ_TREE) {
893-
warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.",
893+
warning(_("omitting tag %s,\nsince tags of trees (or tags "
894+
"of tags of trees, etc.) are not supported."),
894895
oid_to_hex(&tag->object.oid));
895896
return;
896897
}
897898

898899
buf = odb_read_object(the_repository->objects, &tag->object.oid,
899900
&type, &size);
900901
if (!buf)
901-
die("could not read tag %s", oid_to_hex(&tag->object.oid));
902+
die(_("could not read tag %s"), oid_to_hex(&tag->object.oid));
902903
message = memmem(buf, size, "\n\n", 2);
903904
if (message) {
904905
message += 2;
@@ -935,17 +936,17 @@ static void handle_tag(const char *name, struct tag *tag)
935936
if (sig_offset < message_size)
936937
switch (signed_tag_mode) {
937938
case SIGN_ABORT:
938-
die("encountered signed tag %s; use "
939-
"--signed-tags=<mode> to handle it",
939+
die(_("encountered signed tag %s; use "
940+
"--signed-tags=<mode> to handle it"),
940941
oid_to_hex(&tag->object.oid));
941942
case SIGN_WARN_VERBATIM:
942-
warning("exporting signed tag %s",
943+
warning(_("exporting signed tag %s"),
943944
oid_to_hex(&tag->object.oid));
944945
/* fallthru */
945946
case SIGN_VERBATIM:
946947
break;
947948
case SIGN_WARN_STRIP:
948-
warning("stripping signature from tag %s",
949+
warning(_("stripping signature from tag %s"),
949950
oid_to_hex(&tag->object.oid));
950951
/* fallthru */
951952
case SIGN_STRIP:
@@ -960,16 +961,16 @@ static void handle_tag(const char *name, struct tag *tag)
960961
if (!tagged_mark) {
961962
switch (tag_of_filtered_mode) {
962963
case TAG_FILTERING_ABORT:
963-
die("tag %s tags unexported object; use "
964-
"--tag-of-filtered-object=<mode> to handle it",
964+
die(_("tag %s tags unexported object; use "
965+
"--tag-of-filtered-object=<mode> to handle it"),
965966
oid_to_hex(&tag->object.oid));
966967
case DROP:
967968
/* Ignore this tag altogether */
968969
free(buf);
969970
return;
970971
case REWRITE:
971972
if (tagged->type == OBJ_TAG && !mark_tags) {
972-
die(_("Error: Cannot export nested tags unless --mark-tags is specified."));
973+
die(_("cannot export nested tags unless --mark-tags is specified."));
973974
} else if (tagged->type == OBJ_COMMIT) {
974975
p = rewrite_commit((struct commit *)tagged);
975976
if (!p) {
@@ -1025,7 +1026,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, const char *full_n
10251026
tag = (struct tag *)tag->tagged;
10261027
}
10271028
if (!tag)
1028-
die("Tag %s points nowhere?", e->name);
1029+
die(_("tag %s points nowhere?"), e->name);
10291030
return (struct commit *)tag;
10301031
}
10311032
default:
@@ -1063,7 +1064,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
10631064

10641065
commit = get_commit(e, full_name);
10651066
if (!commit) {
1066-
warning("%s: Unexpected object of type %s, skipping.",
1067+
warning(_("%s: unexpected object of type %s, skipping."),
10671068
e->name,
10681069
type_name(e->item->type));
10691070
free(full_name);
@@ -1078,7 +1079,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
10781079
free(full_name);
10791080
continue;
10801081
default: /* OBJ_TAG (nested tags) is already handled */
1081-
warning("Tag points to object of unexpected type %s, skipping.",
1082+
warning(_("tag points to object of unexpected type %s, skipping."),
10821083
type_name(commit->object.type));
10831084
free(full_name);
10841085
continue;
@@ -1174,7 +1175,7 @@ static void export_marks(char *file)
11741175

11751176
f = fopen_for_writing(file);
11761177
if (!f)
1177-
die_errno("Unable to open marks file %s for writing.", file);
1178+
die_errno(_("unable to open marks file %s for writing."), file);
11781179

11791180
for (i = 0; i < idnums.size; i++) {
11801181
if (deco->base && deco->base->type == 1) {
@@ -1191,7 +1192,7 @@ static void export_marks(char *file)
11911192
e |= ferror(f);
11921193
e |= fclose(f);
11931194
if (e)
1194-
error("Unable to write marks file %s.", file);
1195+
error(_("unable to write marks file %s."), file);
11951196
}
11961197

11971198
static void import_marks(char *input_file, int check_exists)
@@ -1214,33 +1215,33 @@ static void import_marks(char *input_file, int check_exists)
12141215

12151216
line_end = strchr(line, '\n');
12161217
if (line[0] != ':' || !line_end)
1217-
die("corrupt mark line: %s", line);
1218+
die(_("corrupt mark line: %s"), line);
12181219
*line_end = '\0';
12191220

12201221
mark = strtoumax(line + 1, &mark_end, 10);
12211222
if (!mark || mark_end == line + 1
12221223
|| *mark_end != ' ' || get_oid_hex(mark_end + 1, &oid))
1223-
die("corrupt mark line: %s", line);
1224+
die(_("corrupt mark line: %s"), line);
12241225

12251226
if (last_idnum < mark)
12261227
last_idnum = mark;
12271228

12281229
type = odb_read_object_info(the_repository->objects, &oid, NULL);
12291230
if (type < 0)
1230-
die("object not found: %s", oid_to_hex(&oid));
1231+
die(_("object not found: %s"), oid_to_hex(&oid));
12311232

12321233
if (type != OBJ_COMMIT)
12331234
/* only commits */
12341235
continue;
12351236

12361237
commit = lookup_commit(the_repository, &oid);
12371238
if (!commit)
1238-
die("not a commit? can't happen: %s", oid_to_hex(&oid));
1239+
die(_("not a commit? can't happen: %s"), oid_to_hex(&oid));
12391240

12401241
object = &commit->object;
12411242

12421243
if (object->flags & SHOWN)
1243-
error("Object %s already has a mark", oid_to_hex(&oid));
1244+
error(_("object %s already has a mark"), oid_to_hex(&oid));
12441245

12451246
mark_object(object, mark);
12461247

@@ -1394,7 +1395,7 @@ int cmd_fast_export(int argc,
13941395
get_tags_and_duplicates(&revs.cmdline);
13951396

13961397
if (prepare_revision_walk(&revs))
1397-
die("revision walk setup failed");
1398+
die(_("revision walk setup failed"));
13981399

13991400
revs.reverse = 1;
14001401
revs.diffopt.format_callback = show_filemodify;

0 commit comments

Comments
 (0)