Re: [PATCH 20/22] sha1-file.c: mark more strings for translation

2018-06-03 Thread Eric Sunshine
On Sat, Jun 2, 2018 at 12:32 AM, Nguyễn Thái Ngọc Duy  wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy 
> ---
> diff --git a/sha1-file.c b/sha1-file.c
> @@ -71,17 +71,17 @@ static void git_hash_sha1_final(unsigned char *hash, 
> git_hash_ctx *ctx)
>  static void git_hash_unknown_init(git_hash_ctx *ctx)
>  {
> -   die("trying to init unknown hash");
> +   die(_("trying to init unknown hash"));
>  }
>
>  static void git_hash_unknown_update(git_hash_ctx *ctx, const void *data, 
> size_t len)
>  {
> -   die("trying to update unknown hash");
> +   die(_("trying to update unknown hash"));
>  }
>
>  static void git_hash_unknown_final(unsigned char *hash, git_hash_ctx *ctx)
>  {
> -   die("trying to finalize unknown hash");
> +   die(_("trying to finalize unknown hash"));
>  }

The above three are indicative of programmer error, aren't they? If
so, they ought not be translated (and perhaps changed to BUG at some
point).

>  const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
> @@ -378,8 +378,8 @@ static int alt_odb_usable(struct raw_object_store *o,
>
> /* Detect cases where alternate disappeared */
> if (!is_directory(path->buf)) {
> -   error("object directory %s does not exist; "
> - "check .git/objects/info/alternates.",
> +   error(_("object directory %s does not exist; "
> +   "check .git/objects/info/alternates."),

Perhaps drop the trailing period as you did in other cases.

>   path->buf);
> return 0;
> }


[PATCH 20/22] sha1-file.c: mark more strings for translation

2018-06-01 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 sha1-file.c | 110 ++--
 1 file changed, 55 insertions(+), 55 deletions(-)

diff --git a/sha1-file.c b/sha1-file.c
index 555e780f4b..ab055181ec 100644
--- a/sha1-file.c
+++ b/sha1-file.c
@@ -71,17 +71,17 @@ static void git_hash_sha1_final(unsigned char *hash, 
git_hash_ctx *ctx)
 
 static void git_hash_unknown_init(git_hash_ctx *ctx)
 {
-   die("trying to init unknown hash");
+   die(_("trying to init unknown hash"));
 }
 
 static void git_hash_unknown_update(git_hash_ctx *ctx, const void *data, 
size_t len)
 {
-   die("trying to update unknown hash");
+   die(_("trying to update unknown hash"));
 }
 
 static void git_hash_unknown_final(unsigned char *hash, git_hash_ctx *ctx)
 {
-   die("trying to finalize unknown hash");
+   die(_("trying to finalize unknown hash"));
 }
 
 const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
@@ -378,8 +378,8 @@ static int alt_odb_usable(struct raw_object_store *o,
 
/* Detect cases where alternate disappeared */
if (!is_directory(path->buf)) {
-   error("object directory %s does not exist; "
- "check .git/objects/info/alternates.",
+   error(_("object directory %s does not exist; "
+   "check .git/objects/info/alternates."),
  path->buf);
return 0;
}
@@ -429,7 +429,7 @@ static int link_alt_odb_entry(struct repository *r, const 
char *entry,
strbuf_addstr(&pathbuf, entry);
 
if (strbuf_normalize_path(&pathbuf) < 0 && relative_base) {
-   error("unable to normalize alternate object path: %s",
+   error(_("unable to normalize alternate object path: %s"),
  pathbuf.buf);
strbuf_release(&pathbuf);
return -1;
@@ -500,14 +500,14 @@ static void link_alt_odb_entries(struct repository *r, 
const char *alt,
return;
 
if (depth > 5) {
-   error("%s: ignoring alternate object stores, nesting too deep.",
+   error(_("%s: ignoring alternate object stores, nesting too 
deep"),
relative_base);
return;
}
 
strbuf_add_absolute_path(&objdirbuf, r->objects->objectdir);
if (strbuf_normalize_path(&objdirbuf) < 0)
-   die("unable to normalize object directory: %s",
+   die(_("unable to normalize object directory: %s"),
objdirbuf.buf);
 
while (*alt) {
@@ -562,7 +562,7 @@ void add_to_alternates_file(const char *reference)
hold_lock_file_for_update(&lock, alts, LOCK_DIE_ON_ERROR);
out = fdopen_lock_file(&lock, "w");
if (!out)
-   die_errno("unable to fdopen alternates lockfile");
+   die_errno(_("unable to fdopen alternates lockfile"));
 
in = fopen(alts, "r");
if (in) {
@@ -580,14 +580,14 @@ void add_to_alternates_file(const char *reference)
fclose(in);
}
else if (errno != ENOENT)
-   die_errno("unable to read alternates file");
+   die_errno(_("unable to read alternates file"));
 
if (found) {
rollback_lock_file(&lock);
} else {
fprintf_or_die(out, "%s\n", reference);
if (commit_lock_file(&lock))
-   die_errno("unable to move new alternates file into 
place");
+   die_errno(_("unable to move new alternates file into 
place"));
if (the_repository->objects->alt_odb_tail)
link_alt_odb_entries(the_repository, reference,
 '\n', NULL, 0);
@@ -778,7 +778,7 @@ static void mmap_limit_check(size_t length)
limit = SIZE_MAX;
}
if (length > limit)
-   die("attempting to mmap %"PRIuMAX" over limit %"PRIuMAX,
+   die(_("attempting to mmap %"PRIuMAX" over limit %"PRIuMAX),
(uintmax_t)length, (uintmax_t)limit);
 }
 
@@ -803,7 +803,7 @@ void *xmmap(void *start, size_t length,
 {
void *ret = xmmap_gently(start, length, prot, flags, fd, offset);
if (ret == MAP_FAILED)
-   die_errno("mmap failed");
+   die_errno(_("mmap failed"));
return ret;
 }
 
@@ -970,7 +970,7 @@ static void *map_sha1_file_1(struct repository *r, const 
char *path,
*size = xsize_t(st.st_size);
if (!*size) {
/* mmap() is forbidden on empty files */
-   error("object file %s is empty", path);
+   error(_("object file %s is empty"), path);
return NULL;
}
map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0