diff mbox series

[v5,4/5] pack-bitmap.c: retrieve missing i18n translations

Message ID 065b7c9ccb5a412526a934f9b67c8be64a40fc7f.1656403084.git.dyroneteng@gmail.com (mailing list archive)
State New, archived
Headers show
Series tr2: avoid to print "interesting" config repeatedly | expand

Commit Message

Teng Long June 28, 2022, 8:17 a.m. UTC
In pack-bitmap.c, some printed texts are translated,some are not.
Let's support the translations of the bitmap related output.

Signed-off-by: Teng Long <dyroneteng@gmail.com>
---
 pack-bitmap.c | 76 +++++++++++++++++++++++++--------------------------
 1 file changed, 38 insertions(+), 38 deletions(-)

Comments

Ævar Arnfjörð Bjarmason June 28, 2022, 8:58 a.m. UTC | #1
On Tue, Jun 28 2022, Teng Long wrote:

> In pack-bitmap.c, some printed texts are translated,some are not.
> Let's support the translations of the bitmap related output.

Usually we don't go for cleanup-while-at-it, but in this case we're
marking messages that don't conform to our CodingGudielines for
translation, mostly because they're error messages that start with an
upper-case letter.

So I think we should fix those issues first, to avoid double-work for
translators (well, a bit less, since they're the translation memory, but
it's quite a bit of churn...).

> -		error("Failed to load bitmap index (corrupted?)");
> +		error(_("Failed to load bitmap index (corrupted?)"));

e.g. here.

> -		return error("Corrupted bitmap index (too small)");
> +		return error(_("Corrupted bitmap index (too small)"));

..and here, etc. etc.

> -		return error("Unsupported version for bitmap index file (%d)", index->version);
> +		return error(_("Unsupported version for bitmap index file (%d)"), index->version);

Let's say "unsupported version '%d' for ..." instead?

> -			return error("Unsupported options for bitmap index file "
> -				"(Git requires BITMAP_OPT_FULL_DAG)");
> +			return error(_("Unsupported options for bitmap index file "
> +				"(Git requires BITMAP_OPT_FULL_DAG)"));

I'm not sure, but shouldn't this be a BUG()?

> -		error("Duplicate entry in bitmap index: %s", oid_to_hex(oid));
> +		error(_("Duplicate entry in bitmap index: %s"), oid_to_hex(oid));

Ditto upper-case, but add '%s' while at it.

>  	if (!strip_suffix(p->pack_name, ".pack", &len))
> -		BUG("pack_name does not end in .pack");
> +		BUG(_("pack_name does not end in .pack"));

Do not translate BUG() messages.

> -		warning("ignoring extra bitmap file: %s", buf.buf);
> +		warning(_("ignoring extra bitmap file: %s"), buf.buf);

Quote the name.

> -		warning("ignoring extra bitmap file: %s", packfile->pack_name);
> +		warning(_("ignoring extra bitmap file: %s"), packfile->pack_name);

ditto.

>  		if (prepare_revision_walk(revs))
> -			die("revision walk setup failed");
> +			die(_("revision walk setup failed"));

Looks good, but aside from this we should really have a tree-wide
xprepare_revision_walk() or something, we have this copy/pasted all over
the place...


> -		BUG("filter_bitmap_tree_depth given non-zero limit");
> +		BUG(_("filter_bitmap_tree_depth given non-zero limit"));

Ditto BUG.
>  
>  	filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter,
>  				   OBJ_TREE);
> @@ -1148,7 +1148,7 @@ static void filter_bitmap_object_type(struct bitmap_index *bitmap_git,
>  				      enum object_type object_type)
>  {
>  	if (object_type < OBJ_COMMIT || object_type > OBJ_TAG)
> -		BUG("filter_bitmap_object_type given invalid object");
> +		BUG(_("filter_bitmap_object_type given invalid object"));
>  
>  	if (object_type != OBJ_TAG)
>  		filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_TAG);
> @@ -1304,14 +1304,14 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
>  		revs->ignore_missing_links = 0;
>  
>  		if (haves_bitmap == NULL)
> -			BUG("failed to perform bitmap walk");
> +			BUG(_("failed to perform bitmap walk"));
>  	}

etc. etc.

>  
>  	wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap,
>  				    filter);
>  
>  	if (!wants_bitmap)
> -		BUG("failed to perform bitmap walk");
> +		BUG(_("failed to perform bitmap walk"));
>  
>  	if (haves_bitmap)
>  		bitmap_and_not(wants_bitmap, haves_bitmap);
> @@ -1432,7 +1432,7 @@ uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git)
>  {
>  	struct multi_pack_index *m = bitmap_git->midx;
>  	if (!m)
> -		BUG("midx_preferred_pack: requires non-empty MIDX");
> +		BUG(_("midx_preferred_pack: requires non-empty MIDX"));

etc. etc.

>  	return nth_midxed_pack_int_id(m, pack_pos_to_midx(bitmap_git->midx, 0));
>  }
>  
> @@ -1629,15 +1629,15 @@ static void test_bitmap_type(struct bitmap_test_data *tdata,
>  	}
>  
>  	if (bitmap_type == OBJ_NONE)
> -		die("object %s not found in type bitmaps",
> +		die(_("object %s not found in type bitmaps"),
>  		    oid_to_hex(&obj->oid));
>  
>  	if (bitmaps_nr > 1)
> -		die("object %s does not have a unique type",
> +		die(_("object %s does not have a unique type"),
>  		    oid_to_hex(&obj->oid));
>  
>  	if (bitmap_type != obj->type)
> -		die("object %s: real type %s, expected: %s",
> +		die(_("object %s: real type %s, expected: %s"),
>  		    oid_to_hex(&obj->oid),
>  		    type_name(obj->type),
>  		    type_name(bitmap_type));

quote %s for these.

> @@ -1651,7 +1651,7 @@ static void test_show_object(struct object *object, const char *name,
>  
>  	bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid);
>  	if (bitmap_pos < 0)
> -		die("Object not in bitmap: %s\n", oid_to_hex(&object->oid));
> +		die(_("Object not in bitmap: %s\n"), oid_to_hex(&object->oid));

Lose the \n here, in addition to lower-case & quote %s.

>  	test_bitmap_type(tdata, object, bitmap_pos);
>  
>  	bitmap_set(tdata->base, bitmap_pos);
> @@ -1666,7 +1666,7 @@ static void test_show_commit(struct commit *commit, void *data)
>  	bitmap_pos = bitmap_position(tdata->bitmap_git,
>  				     &commit->object.oid);
>  	if (bitmap_pos < 0)
> -		die("Object not in bitmap: %s\n", oid_to_hex(&commit->object.oid));
> +		die(_("Object not in bitmap: %s\n"), oid_to_hex(&commit->object.oid));

Ditto.

>  	test_bitmap_type(tdata, &commit->object, bitmap_pos);
>  
>  	bitmap_set(tdata->base, bitmap_pos);
> @@ -1683,26 +1683,26 @@ void test_bitmap_walk(struct rev_info *revs)
>  	struct ewah_bitmap *bm;
>  
>  	if (!(bitmap_git = prepare_bitmap_git(revs->repo)))
> -		die("failed to load bitmap indexes");
> +		die(_("failed to load bitmap indexes"));
>  
>  	if (revs->pending.nr != 1)
> -		die("you must specify exactly one commit to test");
> +		die(_("you must specify exactly one commit to test"));
>  
> -	fprintf(stderr, "Bitmap v%d test (%d entries loaded)\n",
> +	fprintf(stderr, _("Bitmap v%d test (%d entries loaded)\n"),
>  		bitmap_git->version, bitmap_git->entry_count);
>  
>  	root = revs->pending.objects[0].item;
>  	bm = bitmap_for_commit(bitmap_git, (struct commit *)root);
>  
>  	if (bm) {
> -		fprintf(stderr, "Found bitmap for %s. %d bits / %08x checksum\n",
> +		fprintf(stderr, _("Found bitmap for %s. %d bits / %08x checksum\n"),
>  			oid_to_hex(&root->oid), (int)bm->bit_size, ewah_checksum(bm));
>  
>  		result = ewah_to_bitmap(bm);
>  	}
>  
>  	if (result == NULL)
> -		die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
> +		die(_("Commit %s doesn't have an indexed bitmap"), oid_to_hex(&root->oid));
>  
>  	revs->tag_objects = 1;
>  	revs->tree_objects = 1;
> @@ -1711,7 +1711,7 @@ void test_bitmap_walk(struct rev_info *revs)
>  	result_popcnt = bitmap_popcount(result);
>  
>  	if (prepare_revision_walk(revs))
> -		die("revision walk setup failed");
> +		die(_("revision walk setup failed"));
>  
>  	tdata.bitmap_git = bitmap_git;
>  	tdata.base = bitmap_new();
> @@ -1719,7 +1719,7 @@ void test_bitmap_walk(struct rev_info *revs)
>  	tdata.trees = ewah_to_bitmap(bitmap_git->trees);
>  	tdata.blobs = ewah_to_bitmap(bitmap_git->blobs);
>  	tdata.tags = ewah_to_bitmap(bitmap_git->tags);
> -	tdata.prg = start_progress("Verifying bitmap entries", result_popcnt);
> +	tdata.prg = start_progress(_("Verifying bitmap entries"), result_popcnt);

Good catch!
>  	tdata.seen = 0;
>  
>  	traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);
> @@ -1727,9 +1727,9 @@ void test_bitmap_walk(struct rev_info *revs)
>  	stop_progress(&tdata.prg);
>  
>  	if (bitmap_equals(result, tdata.base))
> -		fprintf(stderr, "OK!\n");
> +		fprintf(stderr, _("OK!\n"));

Ditto don't include \n.
>  	else
> -		die("mismatch in bitmap results");
> +		die(_("mismatch in bitmap results"));
>  
>  	bitmap_free(result);
>  	bitmap_free(tdata.base);
> @@ -1747,7 +1747,7 @@ int test_bitmap_commits(struct repository *r)
>  	MAYBE_UNUSED void *value;
>  
>  	if (!bitmap_git)
> -		die("failed to load bitmap indexes");
> +		die(_("failed to load bitmap indexes"));
>  
>  	kh_foreach(bitmap_git->bitmaps, oid, value, {
>  		printf("%s\n", oid_to_hex(&oid));
> @@ -1825,8 +1825,8 @@ uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
>  	if (!bitmap_is_midx(bitmap_git))
>  		load_reverse_index(bitmap_git);
>  	else if (load_midx_revindex(bitmap_git->midx) < 0)
> -		BUG("rebuild_existing_bitmaps: missing required rev-cache "
> -		    "extension");
> +		BUG(_("rebuild_existing_bitmaps: missing required rev-cache "
> +		    "extension"));
>  

Ditto don't translate BUG().
Eric Sunshine June 28, 2022, 5:28 p.m. UTC | #2
On Tue, Jun 28, 2022 at 5:13 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> On Tue, Jun 28 2022, Teng Long wrote:
> >       if (bitmap_equals(result, tdata.base))
> > -             fprintf(stderr, "OK!\n");
> > +             fprintf(stderr, _("OK!\n"));

As a minor additional bit of help, you can use fprintf_ln() from
strbuf.h which will automatically output the trailing "\n":

    frpintf_ln(stderr, _("OK!"));

(Aside: Use of fprintf() here is a bit odd since there are no
formatting directives in the argument, thus fputs() would have been a
better choice, but that's a cleanup for another day and a different
patch series, probably.)
Junio C Hamano June 28, 2022, 6:07 p.m. UTC | #3
Teng Long <dyroneteng@gmail.com> writes:

> Subject: Re: [PATCH v5 4/5] pack-bitmap.c: retrieve missing i18n translations

The verb "retrieve" is puzzling.

> In pack-bitmap.c, some printed texts are translated,some are not.

"," -> ", ".

> Let's support the translations of the bitmap related output.

>  	if (bitmap_size < 0) {
> -		error("Failed to load bitmap index (corrupted?)");
> +		error(_("Failed to load bitmap index (corrupted?)"));

If we were to do this, to avoid burdening translators with double
work, we probably would want to fix the "C" locale version of the
string, either as a preliminary clean-up before this step, or as
part of this step.  From Documentation/CodingGuidelines:

        Error Messages

         - Do not end error messages with a full stop.

         - Do not capitalize the first word, only because it is the first word
           in the message ("unable to open %s", not "Unable to open %s").  But
           "SHA-3 not supported" is fine, because the reason the first word is
           capitalized is not because it is at the beginning of the sentence,
           but because the word would be spelled in capital letters even when
           it appeared in the middle of the sentence.

         - Say what the error is first ("cannot open %s", not "%s: cannot open")
Teng Long July 6, 2022, 2:06 p.m. UTC | #4
> Usually we don't go for cleanup-while-at-it, but in this case we're
> marking messages that don't conform to our CodingGudielines for
> translation, mostly because they're error messages that start with an
> upper-case letter.
>
> So I think we should fix those issues first, to avoid double-work for
> translators (well, a bit less, since they're the translation memory, but
> it's quite a bit of churn...).

Yes. I think it's need to make a cleanup commit first.

> Lose the \n here, in addition to lower-case & quote %s.
> ...
> Ditto don't include \n.
> ...
> Ditto don't translate BUG().
> ..

etc.Will fix.

Thanks.
Teng Long July 6, 2022, 2:19 p.m. UTC | #5
On Tue, 28 Jun 2022 13:28:31 -0400, Eric Sunshine wrote:

> > On Tue, Jun 28 2022, Teng Long wrote:
> > >       if (bitmap_equals(result, tdata.base))
> > > -             fprintf(stderr, "OK!\n");
> > > +             fprintf(stderr, _("OK!\n"));
>
> As a minor additional bit of help, you can use fprintf_ln() from
> strbuf.h which will automatically output the trailing "\n":

Yes, agree.

> (Aside: Use of fprintf() here is a bit odd since there are no
> formatting directives in the argument, thus fputs() would have been a
> better choice, but that's a cleanup for another day and a different
> patch series, probably.)

*nod*, by the way, I think I will remove the translation on "OK!", currently I
think it doesnt mean much.

Thanks.
Teng Long July 7, 2022, 11:59 a.m. UTC | #6
On Date: Tue, 28 Jun 2022 11:07:26 -0700, Junio C Hamano wrote:


> The verb "retrieve" is puzzling.

I use "retrieve" because I think they should be there but actually missing.
But If it's not appropriate here I will change another word like "add".

> "," -> ", ".

Yes.

> If we were to do this, to avoid burdening translators with double
> work, we probably would want to fix the "C" locale version of the
> string, either as a preliminary clean-up before this step, or as
> part of this step.  From Documentation/CodingGuidelines:

Yes.

Does git have any NOT "C" Locale string?

Another doublt is I found something like in:

    File: ./contrib/completion/git-completion.bash
    923    LANG=C LC_ALL=C git merge -s help 2>&1

I think LC_ALL=C will override LANG=C in these cases, so I think
`LC_ALL=C git merge -s help 2>&1` is OK here.

From: https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html#Locale-Environment-Variables.

> Error Messages
>
>  - Do not end error messages with a full stop.
>
>  - Do not capitalize the first word, only because it is the first word
>    in the message ("unable to open %s", not "Unable to open %s").  But
>    "SHA-3 not supported" is fine, because the reason the first word is
>    capitalized is not because it is at the beginning of the sentence,
>    but because the word would be spelled in capital letters even when
>    it appeared in the middle of the sentence.
>
>  - Say what the error is first ("cannot open %s", not "%s: cannot open")

Helpful, fill in blind spots.

Actually, in tr2 some text are printed as capitalized the first word. Is this
entry appropriate for this situation? Whether we should unify the both?
Junio C Hamano July 7, 2022, 4:45 p.m. UTC | #7
Teng Long <dyroneteng@gmail.com> writes:

> On Date: Tue, 28 Jun 2022 11:07:26 -0700, Junio C Hamano wrote:
>
>
>> The verb "retrieve" is puzzling.
>
> I use "retrieve" because I think they should be there but actually missing.
> But If it's not appropriate here I will change another word like "add".

To retrieve is to get/bring something back and regaining possession
of, which implies that the thing existed somewhere already but at a
wrong/different place, and the only thing you are doing is to move
it to the right place, but in this case, the translations did not
exist.  The patch is marking more strings for translation.  And the
act of marking them for translation will cause i18n/l10n folks to
translate these strings, which will (finally) allow _("...") to
retrieve the translated strings at runtime.

So "retrieve" is indeed involved somewhere in the process, but using
the verb skips a few steps.

    Subject: [PATCH 4/5] pack-bitmap.c: mark more strings for translations

perhaps?

>> If we were to do this, to avoid burdening translators with double
>> work, we probably would want to fix the "C" locale version of the
>> string, either as a preliminary clean-up before this step, or as
>> part of this step.  From Documentation/CodingGuidelines:
>
> Yes.
>
> Does git have any NOT "C" Locale string?

Sorry, but I am not sure what you are asking.  What I meant is that
a hunk like this from the patch in discussion:

 	if (bitmap_size < 0) {
-		error("Failed to load bitmap index (corrupted?)");
+		error(_("Failed to load bitmap index (corrupted?)"));
 		ewah_pool_free(b);
 		return NULL;
 	}

makes translators to first translate the above string, but we will
fix the "C" locale version (that is, the string inside _() that is
used as the key to the .po database when retrieving the translated
version) to follow our error message formatting convention to read
something like

	error(_("failed to load bitmap index (corrupted?)"));

or even

	error(_("failed to load bitmap index (corrupted?): '%s'"),
	      filename);

And the translators have to redo the work.  If a preliminary patch
fixed these up before bothering translators with more strings to
translate, they do not need to translate the current, known to be
faulty, version of messages.

> Another doublt is I found something like in:
>
>     File: ./contrib/completion/git-completion.bash
>     923    LANG=C LC_ALL=C git merge -s help 2>&1
>
> I think LC_ALL=C will override LANG=C in these cases, so I think
> `LC_ALL=C git merge -s help 2>&1` is OK here.

In practice, yes, but the code is following the convention to reduce
common confusion caused by leaving some lower precedence but common
environment variables (i.e. LANG) as their original values.

Does the line in the completion script have anything to do with
[PATCH 4/5], or is this merely your curiosity?  Avoid mixing in
unrelated things into the topic, which will only make the review
cycle unnecessarily longer, but raise a separate discussion if you
have to.

Thanks.
Teng Long July 11, 2022, 11:04 a.m. UTC | #8
> To retrieve is to get/bring something back and regaining possession
> of, which implies that the thing existed somewhere already but at a
> wrong/different place, and the only thing you are doing is to move
> it to the right place, but in this case, the translations did not
> exist.  The patch is marking more strings for translation.  And the
> act of marking them for translation will cause i18n/l10n folks to
> translate these strings, which will (finally) allow _("...") to
> retrieve the translated strings at runtime.
>
> So "retrieve" is indeed involved somewhere in the process, but using
> the verb skips a few steps.
>
>     Subject: [PATCH 4/5] pack-bitmap.c: mark more strings for translations
>
> perhaps?

Yes. The explanation is clear.


> Sorry, but I am not sure what you are asking.  What I meant is that
> a hunk like this from the patch in discussion:
> 
>  	if (bitmap_size < 0) {
> -		error("Failed to load bitmap index (corrupted?)");
> +		error(_("Failed to load bitmap index (corrupted?)"));
>  		ewah_pool_free(b);
>  		return NULL;
>  	}
> 
> makes translators to first translate the above string, but we will
> fix the "C" locale version (that is, the string inside _() that is
> used as the key to the .po database when retrieving the translated
> version) to follow our error message formatting convention to read
> something like
> 
> 	error(_("failed to load bitmap index (corrupted?)"));
> 
> or even
> 
> 	error(_("failed to load bitmap index (corrupted?): '%s'"),
> 	      filename);
> 
> And the translators have to redo the work.  If a preliminary patch
> fixed these up before bothering translators with more strings to
> translate, they do not need to translate the current, known to be
> faulty, version of messages.

Yes. I understand a bit of that, maybe.  So, if the string is not C locale,
translator will redo because it cannot be a translate key. Another scence is,
if the string is not following the guideline like capitalized first letter,
translator will redo too, we should avoid that. 

> In practice, yes, but the code is following the convention to reduce
> common confusion caused by leaving some lower precedence but common
> environment variables (i.e. LANG) as their original values.

OK.

> Does the line in the completion script have anything to do with
> [PATCH 4/5], or is this merely your curiosity?  Avoid mixing in
> unrelated things into the topic, which will only make the review
> cycle unnecessarily longer, but raise a separate discussion if you
> have to.

Curiosity. 
Sorry for that, I will raise a separate one next time.

Thanks.
diff mbox series

Patch

diff --git a/pack-bitmap.c b/pack-bitmap.c
index 9f60dbf282..922b9cbc54 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -138,7 +138,7 @@  static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index)
 		index->map_size - index->map_pos);
 
 	if (bitmap_size < 0) {
-		error("Failed to load bitmap index (corrupted?)");
+		error(_("Failed to load bitmap index (corrupted?)"));
 		ewah_pool_free(b);
 		return NULL;
 	}
@@ -160,14 +160,14 @@  static int load_bitmap_header(struct bitmap_index *index)
 	size_t header_size = sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz;
 
 	if (index->map_size < header_size + the_hash_algo->rawsz)
-		return error("Corrupted bitmap index (too small)");
+		return error(_("Corrupted bitmap index (too small)"));
 
 	if (memcmp(header->magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE)) != 0)
-		return error("Corrupted bitmap index file (wrong header)");
+		return error(_("Corrupted bitmap index file (wrong header)"));
 
 	index->version = ntohs(header->version);
 	if (index->version != 1)
-		return error("Unsupported version for bitmap index file (%d)", index->version);
+		return error(_("Unsupported version for bitmap index file (%d)"), index->version);
 
 	/* Parse known bitmap format options */
 	{
@@ -176,12 +176,12 @@  static int load_bitmap_header(struct bitmap_index *index)
 		unsigned char *index_end = index->map + index->map_size - the_hash_algo->rawsz;
 
 		if ((flags & BITMAP_OPT_FULL_DAG) == 0)
-			return error("Unsupported options for bitmap index file "
-				"(Git requires BITMAP_OPT_FULL_DAG)");
+			return error(_("Unsupported options for bitmap index file "
+				"(Git requires BITMAP_OPT_FULL_DAG)"));
 
 		if (flags & BITMAP_OPT_HASH_CACHE) {
 			if (cache_size > index_end - index->map - header_size)
-				return error("corrupted bitmap index file (too short to fit hash cache)");
+				return error(_("corrupted bitmap index file (too short to fit hash cache)"));
 			index->hashes = (void *)(index_end - cache_size);
 			index_end -= cache_size;
 		}
@@ -215,7 +215,7 @@  static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
 	 * because the SHA1 already existed on the map. this is bad, there
 	 * shouldn't be duplicated commits in the index */
 	if (ret == 0) {
-		error("Duplicate entry in bitmap index: %s", oid_to_hex(oid));
+		error(_("Duplicate entry in bitmap index: %s"), oid_to_hex(oid));
 		return NULL;
 	}
 
@@ -259,14 +259,14 @@  static int load_bitmap_entries_v1(struct bitmap_index *index)
 		struct object_id oid;
 
 		if (index->map_size - index->map_pos < 6)
-			return error("corrupt ewah bitmap: truncated header for entry %d", i);
+			return error(_("corrupt ewah bitmap: truncated header for entry %d)"), i);
 
 		commit_idx_pos = read_be32(index->map, &index->map_pos);
 		xor_offset = read_u8(index->map, &index->map_pos);
 		flags = read_u8(index->map, &index->map_pos);
 
 		if (nth_bitmap_object_oid(index, &oid, commit_idx_pos) < 0)
-			return error("corrupt ewah bitmap: commit index %u out of range",
+			return error(_("corrupt ewah bitmap: commit index %u out of range"),
 				     (unsigned)commit_idx_pos);
 
 		bitmap = read_bitmap_1(index);
@@ -274,13 +274,13 @@  static int load_bitmap_entries_v1(struct bitmap_index *index)
 			return -1;
 
 		if (xor_offset > MAX_XOR_OFFSET || xor_offset > i)
-			return error("Corrupted bitmap pack index");
+			return error(_("Corrupted bitmap pack index"));
 
 		if (xor_offset > 0) {
 			xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
 
 			if (xor_bitmap == NULL)
-				return error("Invalid XOR offset in bitmap pack index");
+				return error(_("Invalid XOR offset in bitmap pack index"));
 		}
 
 		recent_bitmaps[i % MAX_XOR_OFFSET] = store_bitmap(
@@ -305,7 +305,7 @@  char *pack_bitmap_filename(struct packed_git *p)
 	size_t len;
 
 	if (!strip_suffix(p->pack_name, ".pack", &len))
-		BUG("pack_name does not end in .pack");
+		BUG(_("pack_name does not end in .pack"));
 	return xstrfmt("%.*s.bitmap", (int)len, p->pack_name);
 }
 
@@ -330,7 +330,7 @@  static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
 		struct strbuf buf = STRBUF_INIT;
 		get_midx_filename(&buf, midx->object_dir);
 		/* ignore extra bitmap file; we can only handle one */
-		warning("ignoring extra bitmap file: %s", buf.buf);
+		warning(_("ignoring extra bitmap file: %s"), buf.buf);
 		close(fd);
 		strbuf_release(&buf);
 		return -1;
@@ -387,7 +387,7 @@  static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
 
 	if (bitmap_git->pack || bitmap_git->midx) {
 		/* ignore extra bitmap file; we can only handle one */
-		warning("ignoring extra bitmap file: %s", packfile->pack_name);
+		warning(_("ignoring extra bitmap file: %s"), packfile->pack_name);
 		close(fd);
 		return -1;
 	}
@@ -819,7 +819,7 @@  static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
 		revs->include_check_data = &incdata;
 
 		if (prepare_revision_walk(revs))
-			die("revision walk setup failed");
+			die(_("revision walk setup failed"));
 
 		show_data.bitmap_git = bitmap_git;
 		show_data.base = base;
@@ -1134,7 +1134,7 @@  static void filter_bitmap_tree_depth(struct bitmap_index *bitmap_git,
 				     unsigned long limit)
 {
 	if (limit)
-		BUG("filter_bitmap_tree_depth given non-zero limit");
+		BUG(_("filter_bitmap_tree_depth given non-zero limit"));
 
 	filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter,
 				   OBJ_TREE);
@@ -1148,7 +1148,7 @@  static void filter_bitmap_object_type(struct bitmap_index *bitmap_git,
 				      enum object_type object_type)
 {
 	if (object_type < OBJ_COMMIT || object_type > OBJ_TAG)
-		BUG("filter_bitmap_object_type given invalid object");
+		BUG(_("filter_bitmap_object_type given invalid object"));
 
 	if (object_type != OBJ_TAG)
 		filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_TAG);
@@ -1304,14 +1304,14 @@  struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
 		revs->ignore_missing_links = 0;
 
 		if (haves_bitmap == NULL)
-			BUG("failed to perform bitmap walk");
+			BUG(_("failed to perform bitmap walk"));
 	}
 
 	wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap,
 				    filter);
 
 	if (!wants_bitmap)
-		BUG("failed to perform bitmap walk");
+		BUG(_("failed to perform bitmap walk"));
 
 	if (haves_bitmap)
 		bitmap_and_not(wants_bitmap, haves_bitmap);
@@ -1432,7 +1432,7 @@  uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git)
 {
 	struct multi_pack_index *m = bitmap_git->midx;
 	if (!m)
-		BUG("midx_preferred_pack: requires non-empty MIDX");
+		BUG(_("midx_preferred_pack: requires non-empty MIDX"));
 	return nth_midxed_pack_int_id(m, pack_pos_to_midx(bitmap_git->midx, 0));
 }
 
@@ -1629,15 +1629,15 @@  static void test_bitmap_type(struct bitmap_test_data *tdata,
 	}
 
 	if (bitmap_type == OBJ_NONE)
-		die("object %s not found in type bitmaps",
+		die(_("object %s not found in type bitmaps"),
 		    oid_to_hex(&obj->oid));
 
 	if (bitmaps_nr > 1)
-		die("object %s does not have a unique type",
+		die(_("object %s does not have a unique type"),
 		    oid_to_hex(&obj->oid));
 
 	if (bitmap_type != obj->type)
-		die("object %s: real type %s, expected: %s",
+		die(_("object %s: real type %s, expected: %s"),
 		    oid_to_hex(&obj->oid),
 		    type_name(obj->type),
 		    type_name(bitmap_type));
@@ -1651,7 +1651,7 @@  static void test_show_object(struct object *object, const char *name,
 
 	bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid);
 	if (bitmap_pos < 0)
-		die("Object not in bitmap: %s\n", oid_to_hex(&object->oid));
+		die(_("Object not in bitmap: %s\n"), oid_to_hex(&object->oid));
 	test_bitmap_type(tdata, object, bitmap_pos);
 
 	bitmap_set(tdata->base, bitmap_pos);
@@ -1666,7 +1666,7 @@  static void test_show_commit(struct commit *commit, void *data)
 	bitmap_pos = bitmap_position(tdata->bitmap_git,
 				     &commit->object.oid);
 	if (bitmap_pos < 0)
-		die("Object not in bitmap: %s\n", oid_to_hex(&commit->object.oid));
+		die(_("Object not in bitmap: %s\n"), oid_to_hex(&commit->object.oid));
 	test_bitmap_type(tdata, &commit->object, bitmap_pos);
 
 	bitmap_set(tdata->base, bitmap_pos);
@@ -1683,26 +1683,26 @@  void test_bitmap_walk(struct rev_info *revs)
 	struct ewah_bitmap *bm;
 
 	if (!(bitmap_git = prepare_bitmap_git(revs->repo)))
-		die("failed to load bitmap indexes");
+		die(_("failed to load bitmap indexes"));
 
 	if (revs->pending.nr != 1)
-		die("you must specify exactly one commit to test");
+		die(_("you must specify exactly one commit to test"));
 
-	fprintf(stderr, "Bitmap v%d test (%d entries loaded)\n",
+	fprintf(stderr, _("Bitmap v%d test (%d entries loaded)\n"),
 		bitmap_git->version, bitmap_git->entry_count);
 
 	root = revs->pending.objects[0].item;
 	bm = bitmap_for_commit(bitmap_git, (struct commit *)root);
 
 	if (bm) {
-		fprintf(stderr, "Found bitmap for %s. %d bits / %08x checksum\n",
+		fprintf(stderr, _("Found bitmap for %s. %d bits / %08x checksum\n"),
 			oid_to_hex(&root->oid), (int)bm->bit_size, ewah_checksum(bm));
 
 		result = ewah_to_bitmap(bm);
 	}
 
 	if (result == NULL)
-		die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
+		die(_("Commit %s doesn't have an indexed bitmap"), oid_to_hex(&root->oid));
 
 	revs->tag_objects = 1;
 	revs->tree_objects = 1;
@@ -1711,7 +1711,7 @@  void test_bitmap_walk(struct rev_info *revs)
 	result_popcnt = bitmap_popcount(result);
 
 	if (prepare_revision_walk(revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	tdata.bitmap_git = bitmap_git;
 	tdata.base = bitmap_new();
@@ -1719,7 +1719,7 @@  void test_bitmap_walk(struct rev_info *revs)
 	tdata.trees = ewah_to_bitmap(bitmap_git->trees);
 	tdata.blobs = ewah_to_bitmap(bitmap_git->blobs);
 	tdata.tags = ewah_to_bitmap(bitmap_git->tags);
-	tdata.prg = start_progress("Verifying bitmap entries", result_popcnt);
+	tdata.prg = start_progress(_("Verifying bitmap entries"), result_popcnt);
 	tdata.seen = 0;
 
 	traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);
@@ -1727,9 +1727,9 @@  void test_bitmap_walk(struct rev_info *revs)
 	stop_progress(&tdata.prg);
 
 	if (bitmap_equals(result, tdata.base))
-		fprintf(stderr, "OK!\n");
+		fprintf(stderr, _("OK!\n"));
 	else
-		die("mismatch in bitmap results");
+		die(_("mismatch in bitmap results"));
 
 	bitmap_free(result);
 	bitmap_free(tdata.base);
@@ -1747,7 +1747,7 @@  int test_bitmap_commits(struct repository *r)
 	MAYBE_UNUSED void *value;
 
 	if (!bitmap_git)
-		die("failed to load bitmap indexes");
+		die(_("failed to load bitmap indexes"));
 
 	kh_foreach(bitmap_git->bitmaps, oid, value, {
 		printf("%s\n", oid_to_hex(&oid));
@@ -1825,8 +1825,8 @@  uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
 	if (!bitmap_is_midx(bitmap_git))
 		load_reverse_index(bitmap_git);
 	else if (load_midx_revindex(bitmap_git->midx) < 0)
-		BUG("rebuild_existing_bitmaps: missing required rev-cache "
-		    "extension");
+		BUG(_("rebuild_existing_bitmaps: missing required rev-cache "
+		    "extension"));
 
 	num_objects = bitmap_num_objects(bitmap_git);
 	CALLOC_ARRAY(reposition, num_objects);