i18n: bisect: mark strings for translation

In the last message, involving Q_(), try to mark the message in such way that is suited for RTL (Right to Left) languages. Update test t6030-bisect-porcelain.sh to reflect the changes. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vasco Almeida committed Jun 17, 2016 at 20:21 UTC 14dc4899e535964311dfafc504dac941ecd52432
2 files changed +42 -36
bisect.c
+31 -25
@@ -438,12 +438,12 @@ static void read_bisect_paths(struct argv_array *array)
438 FILE *fp = fopen(filename, "r");
439
440 if (!fp)
441 - die_errno("Could not open file '%s'", filename);
441 + die_errno(_("Could not open file '%s'"), filename);
442
443 while (strbuf_getline_lf(&str, fp) != EOF) {
444 strbuf_trim(&str);
445 if (sq_dequote_to_argv_array(str.buf, array))
446 - die("Badly quoted content in file '%s': %s",
446 + die(_("Badly quoted content in file '%s': %s"),
447 filename, str.buf);
448 }
449
@@ -649,7 +649,7 @@ static void exit_if_skipped_commits(struct commit_list *tried,
649 print_commit_list(tried, "%s\n", "%s\n");
650 if (bad)
651 printf("%s\n", oid_to_hex(bad));
652 - printf("We cannot bisect more!\n");
652 + printf(_("We cannot bisect more!\n"));
653 exit(2);
654 }
655
@@ -702,7 +702,7 @@ static struct commit *get_commit_reference(const unsigned char *sha1)
702 {
703 struct commit *r = lookup_commit_reference(sha1);
704 if (!r)
705 - die("Not a valid commit name %s", sha1_to_hex(sha1));
705 + die(_("Not a valid commit name %s"), sha1_to_hex(sha1));
706 return r;
707 }
708
@@ -726,27 +726,27 @@ static void handle_bad_merge_base(void)
726 char *bad_hex = oid_to_hex(current_bad_oid);
727 char *good_hex = join_sha1_array_hex(&good_revs, ' ');
728 if (!strcmp(term_bad, "bad") && !strcmp(term_good, "good")) {
729 - fprintf(stderr, "The merge base %s is bad.\n"
729 + fprintf(stderr, _("The merge base %s is bad.\n"
730 "This means the bug has been fixed "
731 - "between %s and [%s].\n",
731 + "between %s and [%s].\n"),
732 bad_hex, bad_hex, good_hex);
733 } else if (!strcmp(term_bad, "new") && !strcmp(term_good, "old")) {
734 - fprintf(stderr, "The merge base %s is new.\n"
734 + fprintf(stderr, _("The merge base %s is new.\n"
735 "The property has changed "
736 - "between %s and [%s].\n",
736 + "between %s and [%s].\n"),
737 bad_hex, bad_hex, good_hex);
738 } else {
739 - fprintf(stderr, "The merge base %s is %s.\n"
739 + fprintf(stderr, _("The merge base %s is %s.\n"
740 "This means the first '%s' commit is "
741 - "between %s and [%s].\n",
741 + "between %s and [%s].\n"),
742 bad_hex, term_bad, term_good, bad_hex, good_hex);
743 }
744 exit(3);
745 }
746
747 - fprintf(stderr, "Some %s revs are not ancestor of the %s rev.\n"
747 + fprintf(stderr, _("Some %s revs are not ancestor of the %s rev.\n"
748 "git bisect cannot work properly in this case.\n"
749 - "Maybe you mistook %s and %s revs?\n",
749 + "Maybe you mistook %s and %s revs?\n"),
750 term_good, term_bad, term_good, term_bad);
751 exit(1);
752 }
@@ -757,11 +757,11 @@ static void handle_skipped_merge_base(const unsigned char *mb)
757 char *bad_hex = sha1_to_hex(current_bad_oid->hash);
758 char *good_hex = join_sha1_array_hex(&good_revs, ' ');
759
760 - warning("the merge base between %s and [%s] "
760 + warning(_("the merge base between %s and [%s] "
761 "must be skipped.\n"
762 "So we cannot be sure the first %s commit is "
763 "between %s and %s.\n"
764 - "We continue anyway.",
764 + "We continue anyway."),
765 bad_hex, good_hex, term_bad, mb_hex, bad_hex);
766 free(good_hex);
767 }
@@ -792,7 +792,7 @@ static void check_merge_bases(int no_checkout)
792 } else if (0 <= sha1_array_lookup(&skipped_revs, mb)) {
793 handle_skipped_merge_base(mb);
794 } else {
795 - printf("Bisecting: a merge base must be tested\n");
795 + printf(_("Bisecting: a merge base must be tested\n"));
796 exit(bisect_checkout(mb, no_checkout));
797 }
798 }
@@ -843,7 +843,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
843 int fd;
844
845 if (!current_bad_oid)
846 - die("a %s revision is needed", term_bad);
846 + die(_("a %s revision is needed"), term_bad);
847
848 /* Check if file BISECT_ANCESTORS_OK exists. */
849 if (!stat(filename, &st) && S_ISREG(st.st_mode))
@@ -860,7 +860,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
860 /* Create file BISECT_ANCESTORS_OK. */
861 fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
862 if (fd < 0)
863 - warning_errno("could not create file '%s'",
863 + warning_errno(_("could not create file '%s'"),
864 filename);
865 else
866 close(fd);
@@ -910,7 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
910 *read_good = "good";
911 return;
912 } else {
913 - die_errno("could not read file '%s'", filename);
913 + die_errno(_("could not read file '%s'"), filename);
914 }
915 } else {
916 strbuf_getline_lf(&str, fp);
@@ -936,10 +936,11 @@ int bisect_next_all(const char *prefix, int no_checkout)
936 struct commit_list *tried;
937 int reaches = 0, all = 0, nr, steps;
938 const unsigned char *bisect_rev;
939 + char steps_msg[32];
940
941 read_bisect_terms(&term_bad, &term_good);
942 if (read_bisect_refs())
942 - die("reading bisect refs failed");
943 + die(_("reading bisect refs failed"));
944
945 check_good_are_ancestors_of_bad(prefix, no_checkout);
946
@@ -959,7 +960,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
960 */
961 exit_if_skipped_commits(tried, NULL);
962
962 - printf("%s was both %s and %s\n",
963 + printf(_("%s was both %s and %s\n"),
964 oid_to_hex(current_bad_oid),
965 term_good,
966 term_bad);
@@ -967,8 +968,8 @@ int bisect_next_all(const char *prefix, int no_checkout)
968 }
969
970 if (!all) {
970 - fprintf(stderr, "No testable commit found.\n"
971 - "Maybe you started with bad path parameters?\n");
971 + fprintf(stderr, _("No testable commit found.\n"
972 + "Maybe you started with bad path parameters?\n"));
973 exit(4);
974 }
975
@@ -985,9 +986,14 @@ int bisect_next_all(const char *prefix, int no_checkout)
986
987 nr = all - reaches - 1;
988 steps = estimate_bisect_steps(all);
988 - printf("Bisecting: %d revision%s left to test after this "
989 - "(roughly %d step%s)\n", nr, (nr == 1 ? "" : "s"),
990 - steps, (steps == 1 ? "" : "s"));
989 + xsnprintf(steps_msg, sizeof(steps_msg),
990 + Q_("(roughly %d step)", "(roughly %d steps)", steps),
991 + steps);
992 + /* TRANSLATORS: the last %s will be replaced with
993 + "(roughly %d steps)" translation */
994 + printf(Q_("Bisecting: %d revision left to test after this %s\n",
995 + "Bisecting: %d revisions left to test after this %s\n",
996 + nr), nr, steps_msg);
997
998 return bisect_checkout(bisect_rev, no_checkout);
999 }
t/t6030-bisect-porcelain.sh
+11 -11
@@ -362,7 +362,7 @@ test_expect_success 'bisect starting with a detached HEAD' '
362 test_expect_success 'bisect errors out if bad and good are mistaken' '
363 git bisect reset &&
364 test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error &&
365 - grep "mistook good and bad" rev_list_error &&
365 + test_i18ngrep "mistook good and bad" rev_list_error &&
366 git bisect reset
367 '
368
@@ -404,7 +404,7 @@ test_expect_success 'side branch creation' '
404
405 test_expect_success 'good merge base when good and bad are siblings' '
406 git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt &&
407 - grep "merge base must be tested" my_bisect_log.txt &&
407 + test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
408 grep $HASH4 my_bisect_log.txt &&
409 git bisect good > my_bisect_log.txt &&
410 test_must_fail grep "merge base must be tested" my_bisect_log.txt &&
@@ -413,7 +413,7 @@ test_expect_success 'good merge base when good and bad are siblings' '
413 '
414 test_expect_success 'skipped merge base when good and bad are siblings' '
415 git bisect start "$SIDE_HASH7" "$HASH7" > my_bisect_log.txt &&
416 - grep "merge base must be tested" my_bisect_log.txt &&
416 + test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
417 grep $HASH4 my_bisect_log.txt &&
418 git bisect skip > my_bisect_log.txt 2>&1 &&
419 grep "warning" my_bisect_log.txt &&
@@ -423,11 +423,11 @@ test_expect_success 'skipped merge base when good and bad are siblings' '
423
424 test_expect_success 'bad merge base when good and bad are siblings' '
425 git bisect start "$HASH7" HEAD > my_bisect_log.txt &&
426 - grep "merge base must be tested" my_bisect_log.txt &&
426 + test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
427 grep $HASH4 my_bisect_log.txt &&
428 test_must_fail git bisect bad > my_bisect_log.txt 2>&1 &&
429 - grep "merge base $HASH4 is bad" my_bisect_log.txt &&
430 - grep "fixed between $HASH4 and \[$SIDE_HASH7\]" my_bisect_log.txt &&
429 + test_i18ngrep "merge base $HASH4 is bad" my_bisect_log.txt &&
430 + test_i18ngrep "fixed between $HASH4 and \[$SIDE_HASH7\]" my_bisect_log.txt &&
431 git bisect reset
432 '
433
@@ -460,9 +460,9 @@ test_expect_success 'many merge bases creation' '
460
461 test_expect_success 'good merge bases when good and bad are siblings' '
462 git bisect start "$B_HASH" "$A_HASH" > my_bisect_log.txt &&
463 - grep "merge base must be tested" my_bisect_log.txt &&
463 + test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
464 git bisect good > my_bisect_log2.txt &&
465 - grep "merge base must be tested" my_bisect_log2.txt &&
465 + test_i18ngrep "merge base must be tested" my_bisect_log2.txt &&
466 {
467 {
468 grep "$SIDE_HASH5" my_bisect_log.txt &&
@@ -477,14 +477,14 @@ test_expect_success 'good merge bases when good and bad are siblings' '
477
478 test_expect_success 'optimized merge base checks' '
479 git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt &&
480 - grep "merge base must be tested" my_bisect_log.txt &&
480 + test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
481 grep "$HASH4" my_bisect_log.txt &&
482 git bisect good > my_bisect_log2.txt &&
483 test -f ".git/BISECT_ANCESTORS_OK" &&
484 test "$HASH6" = $(git rev-parse --verify HEAD) &&
485 git bisect bad > my_bisect_log3.txt &&
486 git bisect good "$A_HASH" > my_bisect_log4.txt &&
487 - grep "merge base must be tested" my_bisect_log4.txt &&
487 + test_i18ngrep "merge base must be tested" my_bisect_log4.txt &&
488 test_must_fail test -f ".git/BISECT_ANCESTORS_OK"
489 '
490
@@ -562,7 +562,7 @@ test_expect_success 'skipping away from skipped commit' '
562
563 test_expect_success 'erroring out when using bad path parameters' '
564 test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt &&
565 - grep "bad path parameters" error.txt
565 + test_i18ngrep "bad path parameters" error.txt
566 '
567
568 test_expect_success 'test bisection on bare repo - --no-checkout specified' '