threads / patch / 24943

patch, 13 partsgettextize the first 4 C mainporcelain common commands

Subject: [PATCH 00/13] gettextize the first 4 C mainporcelain common commands

## tl;dr

63 messages between Sep 1, 2010 and Sep 15, 2010. Diffs are folded; open one to read it.

replies: 62people: 5as markdown or json

Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · lore

This series makes the first 4 C mainporcelain common commands translatable with gettext.

I'm avoiding translating things like git-bisect for now simply because I have some scripts to make this easier that are currently aimed at the C code.

    $ grep 'mainporcelain common' *txt
  * git-add                                 mainporcelain common
    git-bisect                              mainporcelain common
  * git-branch                              mainporcelain common
  * git-checkout                            mainporcelain common
  * git-clone                               mainporcelain common
    git-commit                              mainporcelain common
    ...

This is around 3 patches per command (so at this rate I should finish all 22 commands in ~63 patches).

I'm making an effort to split these up into different types of messages for discussion.

Ævar Arnfjörð Bjarmason (13):
  git-clone: use builtin.h to get gettext.h
  gettextize: git-clone basic messages
  gettextize: git-clone "Cloning into" message
  gettextize: git-add basic messages
  gettextize: git-add refresh_index message
  gettextize: git-branch basic messages
  gettextize: git-branch "remote branch '%s' not found" message
  gettextize: git-branch "git branch -v" messages
  gettextize: git-branch "(no branch)" message
  gettextize: git-checkout: our/their version message
  gettextize: git-checkout basic messages
  gettextize: git-checkout describe_detached_head messages
  gettextize: git-checkout "Switched to a .. branch" message
 builtin/add.c      |   46 +++++++++++++-------------
 builtin/branch.c   |   69 +++++++++++++++++++-------------------
 builtin/checkout.c |   93 +++++++++++++++++++++++++++-------------------------
 builtin/clone.c    |   63 ++++++++++++++++++-----------------
 4 files changed, 138 insertions(+), 133 deletions(-)
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 01/13] git-clone: use builtin.h to get gettext.h

Change builtin/clone.c to use builtin.h. The only other command in 'mainporcelain common' which doesn't include it yet is builtin/reset.c

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

This is just here so that the series applies stand-alone to pu. It's made redundant by my "[PATCH] builtin: use builtin.h for all builtin/ commands" patch, but Junio expressed some reservations about it, so here's a more minimal version sufficient for this series.

 builtin/clone.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Show changes to builtin/clone.c +1 −2
diff --git a/builtin/clone.c b/builtin/clone.c
index 19ed640..994d527 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -8,7 +8,7 @@
  * Clone a repository into a different directory that does not yet exist.
  */
 
-#include "cache.h"
+#include "builtin.h"
 #include "parse-options.h"
 #include "fetch-pack.h"
 #include "refs.h"
@@ -16,7 +16,6 @@
 #include "tree-walk.h"
 #include "unpack-trees.h"
 #include "transport.h"
-#include "strbuf.h"
 #include "dir.h"
 #include "pack-refs.h"
 #include "sigchain.h"
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 02/13] gettextize: git-clone basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/clone.c |   54 +++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)
Show changes to builtin/clone.c +27 −27
diff --git a/builtin/clone.c b/builtin/clone.c
index 994d527..0b595ba 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -205,7 +205,7 @@ static void setup_reference(const char *repo)
 	if (is_directory(mkpath("%s/.git/objects", ref_git)))
 		ref_git = mkpath("%s/.git", ref_git);
 	else if (!is_directory(mkpath("%s/objects", ref_git)))
-		die("reference repository '%s' is not a local directory.",
+		die(_("reference repository '%s' is not a local directory."),
 		    option_reference);
 
 	ref_git_copy = xstrdup(ref_git);
@@ -232,15 +232,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 
 	dir = opendir(src->buf);
 	if (!dir)
-		die_errno("failed to open '%s'", src->buf);
+		die_errno(_("failed to open '%s'"), src->buf);
 
 	if (mkdir(dest->buf, 0777)) {
 		if (errno != EEXIST)
-			die_errno("failed to create directory '%s'", dest->buf);
+			die_errno(_("failed to create directory '%s'"), dest->buf);
 		else if (stat(dest->buf, &buf))
-			die_errno("failed to stat '%s'", dest->buf);
+			die_errno(_("failed to stat '%s'"), dest->buf);
 		else if (!S_ISDIR(buf.st_mode))
-			die("%s exists and is not a directory", dest->buf);
+			die(_("%s exists and is not a directory"), dest->buf);
 	}
 
 	strbuf_addch(src, '/');
@@ -254,7 +254,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		strbuf_setlen(dest, dest_len);
 		strbuf_addstr(dest, de->d_name);
 		if (stat(src->buf, &buf)) {
-			warning ("failed to stat %s\n", src->buf);
+			warning (_("failed to stat %s\n"), src->buf);
 			continue;
 		}
 		if (S_ISDIR(buf.st_mode)) {
@@ -264,16 +264,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 		}
 
 		if (unlink(dest->buf) && errno != ENOENT)
-			die_errno("failed to unlink '%s'", dest->buf);
+			die_errno(_("failed to unlink '%s'"), dest->buf);
 		if (!option_no_hardlinks) {
 			if (!link(src->buf, dest->buf))
 				continue;
 			if (option_local)
-				die_errno("failed to create link '%s'", dest->buf);
+				die_errno(_("failed to create link '%s'"), dest->buf);
 			option_no_hardlinks = 1;
 		}
 		if (copy_file_with_time(dest->buf, src->buf, 0666))
-			die_errno("failed to copy file to '%s'", dest->buf);
+			die_errno(_("failed to copy file to '%s'"), dest->buf);
 	}
 	closedir(dir);
 }
@@ -302,7 +302,7 @@ static const struct ref *clone_local(const char *src_repo,
 	ret = transport_get_remote_refs(transport);
 	transport_disconnect(transport);
 	if (0 <= option_verbosity)
-		printf("done.\n");
+		printf(_("done.\n"));
 	return ret;
 }
 
@@ -384,11 +384,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			     builtin_clone_usage, 0);
 
 	if (argc > 2)
-		usage_msg_opt("Too many arguments.",
+		usage_msg_opt(_("Too many arguments."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (argc == 0)
-		usage_msg_opt("You must specify a repository to clone.",
+		usage_msg_opt(_("You must specify a repository to clone."),
 			builtin_clone_usage, builtin_clone_options);
 
 	if (option_mirror)
@@ -396,7 +396,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (option_bare) {
 		if (option_origin)
-			die("--bare and --origin %s options are incompatible.",
+			die(_("--bare and --origin %s options are incompatible."),
 			    option_origin);
 		option_no_checkout = 1;
 	}
@@ -415,7 +415,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		repo = repo_name;
 	is_local = path && !is_bundle;
 	if (is_local && option_depth)
-		warning("--depth is ignored in local clones; use file:// instead.");
+		warning(_("--depth is ignored in local clones; use file:// instead."));
 
 	if (argc == 2)
 		dir = xstrdup(argv[1]);
@@ -425,8 +425,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	dest_exists = !stat(dir, &buf);
 	if (dest_exists && !is_empty_dir(dir))
-		die("destination path '%s' already exists and is not "
-			"an empty directory.", dir);
+		die(_("destination path '%s' already exists and is not "
+			"an empty directory."), dir);
 
 	strbuf_addf(&reflog_msg, "clone: from %s", repo);
 
@@ -435,7 +435,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	else {
 		work_tree = getenv("GIT_WORK_TREE");
 		if (work_tree && !stat(work_tree, &buf))
-			die("working tree '%s' already exists.", work_tree);
+			die(_("working tree '%s' already exists."), work_tree);
 	}
 
 	if (option_bare || work_tree)
@@ -448,10 +448,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	if (!option_bare) {
 		junk_work_tree = work_tree;
 		if (safe_create_leading_directories_const(work_tree) < 0)
-			die_errno("could not create leading directories of '%s'",
+			die_errno(_("could not create leading directories of '%s'"),
 				  work_tree);
 		if (!dest_exists && mkdir(work_tree, 0755))
-			die_errno("could not create work tree dir '%s'.",
+			die_errno(_("could not create work tree dir '%s'."),
 				  work_tree);
 		set_git_work_tree(work_tree);
 	}
@@ -462,7 +462,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1);
 
 	if (safe_create_leading_directories_const(git_dir) < 0)
-		die("could not create leading directories of '%s'", git_dir);
+		die(_("could not create leading directories of '%s'"), git_dir);
 	set_git_dir(make_absolute_path(git_dir));
 
 	if (0 <= option_verbosity)
@@ -524,7 +524,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		transport = transport_get(remote, remote->url[0]);
 
 		if (!transport->get_refs_list || !transport->fetch)
-			die("Don't know how to clone %s", transport->url);
+			die(_("Don't know how to clone %s"), transport->url);
 
 		transport_set_option(transport, TRANS_OPT_KEEP, "yes");
 
@@ -563,8 +563,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			strbuf_release(&head);
 
 			if (!our_head_points_at) {
-				warning("Remote branch %s not found in "
-					"upstream %s, using HEAD instead",
+				warning(_("Remote branch %s not found in "
+					"upstream %s, using HEAD instead"),
 					option_branch, option_origin);
 				our_head_points_at = remote_head_points_at;
 			}
@@ -573,7 +573,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			our_head_points_at = remote_head_points_at;
 	}
 	else {
-		warning("You appear to have cloned an empty repository.");
+		warning(_("You appear to have cloned an empty repository."));
 		our_head_points_at = NULL;
 		remote_head_points_at = NULL;
 		remote_head = NULL;
@@ -615,8 +615,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	} else {
 		/* Nothing to checkout out */
 		if (!option_no_checkout)
-			warning("remote HEAD refers to nonexistent ref, "
-				"unable to checkout.\n");
+			warning(_("remote HEAD refers to nonexistent ref, "
+				"unable to checkout.\n"));
 		option_no_checkout = 1;
 	}
 
@@ -652,7 +652,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 		if (write_cache(fd, active_cache, active_nr) ||
 		    commit_locked_index(lock_file))
-			die("unable to write new index file");
+			die(_("unable to write new index file"));
 
 		err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
 				sha1_to_hex(our_head_points_at->old_sha1), "1",
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 03/13] gettextize: git-clone "Cloning into" message

Split up the "Cloning into %s" and "Cloning into bare repository %s" messages to make them easier to translate.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/clone.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to builtin/clone.c +4 −2
diff --git a/builtin/clone.c b/builtin/clone.c
index 0b595ba..d1cf6dd 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -466,8 +466,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	set_git_dir(make_absolute_path(git_dir));
 
 	if (0 <= option_verbosity)
-		printf("Cloning into %s%s...\n",
-		       option_bare ? "bare repository " : "", dir);
+		if (option_bare)
+			printf(_("Cloning into bare repository %s"), dir);
+		else
+			printf(_("Cloning into %s"), dir);
 	init_db(option_template, INIT_DB_QUIET);
 
 	/*
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 04/13] gettextize: git-add basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/add.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)
Show changes to builtin/add.c +22 −22
diff --git a/builtin/add.c b/builtin/add.c
index 56a4e0a..6578cdd 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -38,7 +38,7 @@ static void update_callback(struct diff_queue_struct *q,
 		const char *path = p->one->path;
 		switch (p->status) {
 		default:
-			die("unexpected diff status %c", p->status);
+			die(_("unexpected diff status %c"), p->status);
 		case DIFF_STATUS_UNMERGED:
 			/*
 			 * ADD_CACHE_IGNORE_REMOVAL is unset if "git
@@ -64,7 +64,7 @@ static void update_callback(struct diff_queue_struct *q,
 		case DIFF_STATUS_TYPE_CHANGED:
 			if (add_file_to_index(&the_index, path, data->flags)) {
 				if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
-					die("updating files failed");
+					die(_("updating files failed"));
 				data->add_errors++;
 			}
 			break;
@@ -74,7 +74,7 @@ static void update_callback(struct diff_queue_struct *q,
 			if (!(data->flags & ADD_CACHE_PRETEND))
 				remove_file_from_index(&the_index, path);
 			if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
-				printf("remove '%s'\n", path);
+				printf(_("remove '%s'\n"), path);
 			break;
 		}
 	}
@@ -172,7 +172,7 @@ static void treat_gitlinks(const char **pathspec)
 					/* strip trailing slash */
 					pathspec[j] = xstrndup(ce->name, len);
 				else
-					die ("Path '%s' is in submodule '%.*s'",
+					die (_("Path '%s' is in submodule '%.*s'"),
 						pathspec[j], len, ce->name);
 			}
 		}
@@ -191,7 +191,7 @@ static void refresh(int verbose, const char **pathspec)
 		      pathspec, seen, "Unstaged changes after refreshing the index:");
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
-			die("pathspec '%s' did not match any files", pathspec[i]);
+			die(_("pathspec '%s' did not match any files"), pathspec[i]);
 	}
         free(seen);
 }
@@ -205,7 +205,7 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
 		for (p = pathspec; *p; p++) {
 			if (has_symlink_leading_path(*p, strlen(*p))) {
 				int len = prefix ? strlen(prefix) : 0;
-				die("'%s' is beyond a symbolic link", *p + len);
+				die(_("'%s' is beyond a symbolic link"), *p + len);
 			}
 		}
 	}
@@ -272,7 +272,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
 
 	if (read_cache() < 0)
-		die ("Could not read the index");
+		die (_("Could not read the index"));
 
 	init_revisions(&rev, prefix);
 	rev.diffopt.context = 7;
@@ -281,24 +281,24 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 	rev.diffopt.output_format = DIFF_FORMAT_PATCH;
 	out = open(file, O_CREAT | O_WRONLY, 0644);
 	if (out < 0)
-		die ("Could not open '%s' for writing.", file);
+		die (_("Could not open '%s' for writing."), file);
 	rev.diffopt.file = xfdopen(out, "w");
 	rev.diffopt.close_file = 1;
 	if (run_diff_files(&rev, 0))
-		die ("Could not write patch");
+		die (_("Could not write patch"));
 
 	launch_editor(file, NULL, NULL);
 
 	if (stat(file, &st))
-		die_errno("Could not stat '%s'", file);
+		die_errno(_("Could not stat '%s'"), file);
 	if (!st.st_size)
-		die("Empty patch. Aborted.");
+		die(_("Empty patch. Aborted."));
 
 	memset(&child, 0, sizeof(child));
 	child.git_cmd = 1;
 	child.argv = apply_argv;
 	if (run_command(&child))
-		die ("Could not apply '%s'", file);
+		die (_("Could not apply '%s'"), file);
 
 	unlink(file);
 	return 0;
@@ -346,14 +346,14 @@ static int add_files(struct dir_struct *dir, int flags)
 		fprintf(stderr, ignore_error);
 		for (i = 0; i < dir->ignored_nr; i++)
 			fprintf(stderr, "%s\n", dir->ignored[i]->name);
-		fprintf(stderr, "Use -f if you really want to add them.\n");
-		die("no files added");
+		fprintf(stderr, _("Use -f if you really want to add them.\n"));
+		die(_("no files added"));
 	}
 
 	for (i = 0; i < dir->nr; i++)
 		if (add_file_to_cache(dir->entries[i]->name, flags)) {
 			if (!ignore_add_errors)
-				die("adding files failed");
+				die(_("adding files failed"));
 			exit_status = 1;
 		}
 	return exit_status;
@@ -385,9 +385,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argv++;
 
 	if (addremove && take_worktree_changes)
-		die("-A and -u are mutually incompatible");
+		die(_("-A and -u are mutually incompatible"));
 	if (!show_only && ignore_missing)
-		die("Option --ignore-missing can only be used together with --dry-run");
+		die(_("Option --ignore-missing can only be used together with --dry-run"));
 	if ((addremove || take_worktree_changes) && !argc) {
 		static const char *here[2] = { ".", NULL };
 		argc = 1;
@@ -407,14 +407,14 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		  ? ADD_CACHE_IGNORE_REMOVAL : 0));
 
 	if (require_pathspec && argc == 0) {
-		fprintf(stderr, "Nothing specified, nothing added.\n");
-		fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+		fprintf(stderr, _("Nothing specified, nothing added.\n"));
+		fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
 		return 0;
 	}
 	pathspec = validate_pathspec(argc, argv, prefix);
 
 	if (read_cache() < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 	treat_gitlinks(pathspec);
 
 	if (add_new_files) {
@@ -449,7 +449,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 					if (excluded(&dir, pathspec[i], DT_UNKNOWN))
 						dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
 				} else
-					die("pathspec '%s' did not match any files",
+					die(_("pathspec '%s' did not match any files"),
 					    pathspec[i]);
 			}
 		}
@@ -465,7 +465,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	if (active_cache_changed) {
 		if (write_cache(newfd, active_cache, active_nr) ||
 		    commit_locked_index(&lock_file))
-			die("Unable to write new index file");
+			die(_("Unable to write new index file"));
 	}
 
 	return exit_status;
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 05/13] gettextize: git-add refresh_index message

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

I can't find the command that makes this message appear, but it seems to be a human-readable header printed by "git-add".

 builtin/add.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to builtin/add.c +1 −1
diff --git a/builtin/add.c b/builtin/add.c
index 6578cdd..eed37bf 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -188,7 +188,7 @@ static void refresh(int verbose, const char **pathspec)
 		/* nothing */;
 	seen = xcalloc(specs, 1);
 	refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,
-		      pathspec, seen, "Unstaged changes after refreshing the index:");
+		      pathspec, seen, _("Unstaged changes after refreshing the index:"));
 	for (i = 0; i < specs; i++) {
 		if (!seen[i])
 			die(_("pathspec '%s' did not match any files"), pathspec[i]);
-- 
1.7.2.2.579.g2183d
Jonathan Nieder· Sep 2, 2010, 04:21 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 05/13] gettextize: git-add refresh_index message

On Wed, Sep 01, 2010 at 08:43:57PM +0000, Ævar Arnfjörð Bjarmason wrote:
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> 
> I can't find the command that makes this message appear

$ git reset HEAD^ 2>/dev/null $ git add -v --refresh . Unstaged changes after refreshing the index: M builtin/apply.c M builtin/bundle.c M builtin/config.c M builtin/grep.c M builtin/index-pack.c M builtin/ls-remote.c M builtin/merge-file.c M builtin/shortlog.c M builtin/var.c M cache.h M environment.c M git.c M setup.c M t/t1501-worktree.sh M t/t7006-pager.sh

Definitely porcelain.
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 06/13] gettextize: git-branch basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/branch.c |   58 +++++++++++++++++++++++++++---------------------------
 1 files changed, 29 insertions(+), 29 deletions(-)
Show changes to builtin/branch.c +29 −29
diff --git a/builtin/branch.c b/builtin/branch.c
index 87976f0..50c15c1 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -133,12 +133,12 @@ static int branch_merged(int kind, const char *name,
 	if ((head_rev != reference_rev) &&
 	    in_merge_bases(rev, &head_rev, 1) != merged) {
 		if (merged)
-			warning("deleting branch '%s' that has been merged to\n"
-				"         '%s', but it is not yet merged to HEAD.",
+			warning(_("deleting branch '%s' that has been merged to\n"
+				"         '%s', but it is not yet merged to HEAD."),
 				name, reference_name);
 		else
-			warning("not deleting branch '%s' that is not yet merged to\n"
-				"         '%s', even though it is merged to HEAD.",
+			warning(_("not deleting branch '%s' that is not yet merged to\n"
+				"         '%s', even though it is merged to HEAD."),
 				name, reference_name);
 	}
 	return merged;
@@ -165,19 +165,19 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 		remote = "";
 		break;
 	default:
-		die("cannot use -a with -d");
+		die(_("cannot use -a with -d"));
 	}
 
 	if (!force) {
 		head_rev = lookup_commit_reference(head_sha1);
 		if (!head_rev)
-			die("Couldn't look up commit object for HEAD");
+			die(_("Couldn't look up commit object for HEAD"));
 	}
 	for (i = 0; i < argc; i++, strbuf_release(&bname)) {
 		strbuf_branchname(&bname, argv[i]);
 		if (kinds == REF_LOCAL_BRANCH && !strcmp(head, bname.buf)) {
-			error("Cannot delete the branch '%s' "
-			      "which you are currently on.", bname.buf);
+			error(_("Cannot delete the branch '%s' "
+			      "which you are currently on."), bname.buf);
 			ret = 1;
 			continue;
 		}
@@ -186,7 +186,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		name = xstrdup(mkpath(fmt, bname.buf));
 		if (!resolve_ref(name, sha1, 1, NULL)) {
-			error("%sbranch '%s' not found.",
+			error(_("%sbranch '%s' not found."),
 					remote, bname.buf);
 			ret = 1;
 			continue;
@@ -194,31 +194,31 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		rev = lookup_commit_reference(sha1);
 		if (!rev) {
-			error("Couldn't look up commit object for '%s'", name);
+			error(_("Couldn't look up commit object for '%s'"), name);
 			ret = 1;
 			continue;
 		}
 
 		if (!force && !branch_merged(kinds, bname.buf, rev, head_rev)) {
-			error("The branch '%s' is not fully merged.\n"
+			error(_("The branch '%s' is not fully merged.\n"
 			      "If you are sure you want to delete it, "
-			      "run 'git branch -D %s'.", bname.buf, bname.buf);
+			      "run 'git branch -D %s'."), bname.buf, bname.buf);
 			ret = 1;
 			continue;
 		}
 
 		if (delete_ref(name, sha1, 0)) {
-			error("Error deleting %sbranch '%s'", remote,
+			error(_("Error deleting %sbranch '%s'"), remote,
 			      bname.buf);
 			ret = 1;
 		} else {
 			struct strbuf buf = STRBUF_INIT;
-			printf("Deleted %sbranch %s (was %s).\n", remote,
+			printf(_("Deleted %sbranch %s (was %s).\n"), remote,
 			       bname.buf,
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
 			if (git_config_rename_section(buf.buf, NULL) < 0)
-				warning("Update of config-file failed");
+				warning(_("Update of config-file failed"));
 			strbuf_release(&buf);
 		}
 	}
@@ -300,7 +300,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
 	if (ref_list->verbose || ref_list->with_commit || merge_filter != NO_FILTER) {
 		commit = lookup_commit_reference_gently(sha1, 1);
 		if (!commit) {
-			cb->ret = error("branch '%s' does not point at a commit", refname);
+			cb->ret = error(_("branch '%s' does not point at a commit"), refname);
 			return 0;
 		}
 
@@ -540,7 +540,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
 	free_ref_list(&ref_list);
 
 	if (cb.ret)
-		error("some refs could not be read");
+		error(_("some refs could not be read"));
 
 	return cb.ret;
 }
@@ -553,7 +553,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 	int recovery = 0;
 
 	if (!oldname)
-		die("cannot rename the current branch while not on any.");
+		die(_("cannot rename the current branch while not on any."));
 
 	if (strbuf_check_branch_ref(&oldref, oldname)) {
 		/*
@@ -563,35 +563,35 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 		if (resolve_ref(oldref.buf, sha1, 1, NULL))
 			recovery = 1;
 		else
-			die("Invalid branch name: '%s'", oldname);
+			die(_("Invalid branch name: '%s'"), oldname);
 	}
 
 	if (strbuf_check_branch_ref(&newref, newname))
-		die("Invalid branch name: '%s'", newname);
+		die(_("Invalid branch name: '%s'"), newname);
 
 	if (resolve_ref(newref.buf, sha1, 1, NULL) && !force)
-		die("A branch named '%s' already exists.", newref.buf + 11);
+		die(_("A branch named '%s' already exists."), newref.buf + 11);
 
 	strbuf_addf(&logmsg, "Branch: renamed %s to %s",
 		 oldref.buf, newref.buf);
 
 	if (rename_ref(oldref.buf, newref.buf, logmsg.buf))
-		die("Branch rename failed");
+		die(_("Branch rename failed"));
 	strbuf_release(&logmsg);
 
 	if (recovery)
-		warning("Renamed a misnamed branch '%s' away", oldref.buf + 11);
+		warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11);
 
 	/* no need to pass logmsg here as HEAD didn't really move */
 	if (!strcmp(oldname, head) && create_symref("HEAD", newref.buf, NULL))
-		die("Branch renamed to %s, but HEAD is not updated!", newname);
+		die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
 
 	strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11);
 	strbuf_release(&oldref);
 	strbuf_addf(&newsection, "branch.%s", newref.buf + 11);
 	strbuf_release(&newref);
 	if (git_config_rename_section(oldsection.buf, newsection.buf) < 0)
-		die("Branch is renamed, but update of config-file failed");
+		die(_("Branch is renamed, but update of config-file failed"));
 	strbuf_release(&oldsection);
 	strbuf_release(&newsection);
 }
@@ -606,7 +606,7 @@ static int opt_parse_merge_filter(const struct option *opt, const char *arg, int
 	if (!arg)
 		arg = "HEAD";
 	if (get_sha1(arg, merge_filter_ref))
-		die("malformed object name %s", arg);
+		die(_("malformed object name %s"), arg);
 	return 0;
 }
 
@@ -676,13 +676,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
 	head = resolve_ref("HEAD", head_sha1, 0, NULL);
 	if (!head)
-		die("Failed to resolve HEAD as a valid ref.");
+		die(_("Failed to resolve HEAD as a valid ref."));
 	head = xstrdup(head);
 	if (!strcmp(head, "HEAD")) {
 		detached = 1;
 	} else {
 		if (prefixcmp(head, "refs/heads/"))
-			die("HEAD not found below refs/heads!");
+			die(_("HEAD not found below refs/heads!"));
 		head += 11;
 	}
 	hashcpy(merge_filter_ref, head_sha1);
@@ -702,7 +702,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		rename_branch(argv[0], argv[1], rename > 1);
 	else if (argc <= 2) {
 		if (kinds != REF_LOCAL_BRANCH)
-			die("-a and -r options to 'git branch' do not make sense with a branch name");
+			die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
 		create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
 			      force_create, reflog, track);
 	} else
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:43 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 07/13] gettextize: git-branch "remote branch '%s' not found" message

This could be done better by splitting it up, but it would change too much code, which I'm trying to avoid at this point. Instead add a TRANSLATORS comment to explain what "remote " does.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/branch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to builtin/branch.c +2 −1
diff --git a/builtin/branch.c b/builtin/branch.c
index 50c15c1..8802033 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -157,7 +157,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 	switch (kinds) {
 	case REF_REMOTE_BRANCH:
 		fmt = "refs/remotes/%s";
-		remote = "remote ";
+		/* TRANSLATORS: This is "remote " in "remote branch '%s' not found" */
+		remote = _("remote ");
 		force = 1;
 		break;
 	case REF_LOCAL_BRANCH:
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 08/13] gettextize: git-branch "git branch -v" messages

Make the "git branch -v" messages translatable, e.g.:
    5054b57 [ahead 8] branch error fixup
This is possibly a plumbing message.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

I don't know whether we consider "git branch -v" output plumbing or not, probably not.

 builtin/branch.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Show changes to builtin/branch.c +3 −3
diff --git a/builtin/branch.c b/builtin/branch.c
index 8802033..59e71fc 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -378,11 +378,11 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
 		strbuf_addf(stat, "%s: ",
 			shorten_unambiguous_ref(branch->merge[0]->dst, 0));
 	if (!ours)
-		strbuf_addf(stat, "behind %d] ", theirs);
+		strbuf_addf(stat, _("behind %d] "), theirs);
 	else if (!theirs)
-		strbuf_addf(stat, "ahead %d] ", ours);
+		strbuf_addf(stat, _("ahead %d] "), ours);
 	else
-		strbuf_addf(stat, "ahead %d, behind %d] ", ours, theirs);
+		strbuf_addf(stat, _("ahead %d, behind %d] "), ours, theirs);
 }
 
 static int matches_merge_filter(struct commit *commit)
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 09/13] gettextize: git-branch "(no branch)" message

This is possibly a plumbing message.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
ditto about the maybe plumbing output, but I think not.
 builtin/branch.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to builtin/branch.c +1 −1
diff --git a/builtin/branch.c b/builtin/branch.c
index 59e71fc..fc6c4c3 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -481,7 +481,7 @@ static void show_detached(struct ref_list *ref_list)
 
 	if (head_commit && is_descendant_of(head_commit, ref_list->with_commit)) {
 		struct ref_item item;
-		item.name = xstrdup("(no branch)");
+		item.name = xstrdup(_("(no branch)"));
 		item.len = strlen(item.name);
 		item.kind = REF_LOCAL_BRANCH;
 		item.dest = NULL;
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 10/13] gettextize: git-checkout: our/their version message

Split up the "does not have our/their version" message to make it easier to translate.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
I'm splitting this sort of thing into an if/else rather than:
    printf(foo ? _("bar") : _("blah"), ...)
because I think the alternative is harder to read.
 builtin/checkout.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
Show changes to builtin/checkout.c +8 −6
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 97bf2ec..a096e3d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -103,9 +103,10 @@ static int check_stage(int stage, struct cache_entry *ce, int pos)
 			return 0;
 		pos++;
 	}
-	return error("path '%s' does not have %s version",
-		     ce->name,
-		     (stage == 2) ? "our" : "their");
+	if (stage == 2)
+		return error(_("path '%s' does not have our version"), ce->name);
+	else
+		return error(_("path '%s' does not have their version"), ce->name);
 }
 
 static int check_all_stages(struct cache_entry *ce, int pos)
@@ -130,9 +131,10 @@ static int checkout_stage(int stage, struct cache_entry *ce, int pos,
 			return checkout_entry(active_cache[pos], state, NULL);
 		pos++;
 	}
-	return error("path '%s' does not have %s version",
-		     ce->name,
-		     (stage == 2) ? "our" : "their");
+	if (stage == 2)
+		return error(_("path '%s' does not have our version"), ce->name);
+	else
+		return error(_("path '%s' does not have their version"), ce->name);
 }
 
 static int checkout_merged(int pos, struct checkout *state)
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 11/13] gettextize: git-checkout basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/checkout.c |   68 ++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)
Show changes to builtin/checkout.c +34 −34
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a096e3d..a7033a0 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -117,7 +117,7 @@ static int check_all_stages(struct cache_entry *ce, int pos)
 	    ce_stage(active_cache[pos+1]) != 2 ||
 	    strcmp(active_cache[pos+2]->name, ce->name) ||
 	    ce_stage(active_cache[pos+2]) != 3)
-		return error("path '%s' does not have all three versions",
+		return error(_("path '%s' does not have all three versions"),
 			     ce->name);
 	return 0;
 }
@@ -152,7 +152,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	    ce_stage(active_cache[pos+1]) != 2 ||
 	    strcmp(active_cache[pos+2]->name, path) ||
 	    ce_stage(active_cache[pos+2]) != 3)
-		return error("path '%s' does not have all 3 versions", path);
+		return error(_("path '%s' does not have all 3 versions"), path);
 
 	read_mmblob(&ancestor, active_cache[pos]->sha1);
 	read_mmblob(&ours, active_cache[pos+1]->sha1);
@@ -169,7 +169,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	free(theirs.ptr);
 	if (status < 0 || !result_buf.ptr) {
 		free(result_buf.ptr);
-		return error("path '%s': cannot merge", path);
+		return error(_("path '%s': cannot merge"), path);
 	}
 
 	/*
@@ -186,12 +186,12 @@ static int checkout_merged(int pos, struct checkout *state)
 	 */
 	if (write_sha1_file(result_buf.ptr, result_buf.size,
 			    blob_type, sha1))
-		die("Unable to add merge result for '%s'", path);
+		die(_("Unable to add merge result for '%s'"), path);
 	ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
 			      sha1,
 			      path, 2, 0);
 	if (!ce)
-		die("make_cache_entry failed for path '%s'", path);
+		die(_("make_cache_entry failed for path '%s'"), path);
 	status = checkout_entry(ce, state, NULL);
 	return status;
 }
@@ -213,7 +213,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
 
 	newfd = hold_locked_index(lock_file, 1);
 	if (read_cache_preload(pathspec) < 0)
-		return error("corrupt index file");
+		return error(_("corrupt index file"));
 
 	if (source_tree)
 		read_tree_some(source_tree, pathspec);
@@ -241,14 +241,14 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
 			if (!ce_stage(ce))
 				continue;
 			if (opts->force) {
-				warning("path '%s' is unmerged", ce->name);
+				warning(_("path '%s' is unmerged"), ce->name);
 			} else if (stage) {
 				errs |= check_stage(stage, ce, pos);
 			} else if (opts->merge) {
 				errs |= check_all_stages(ce, pos);
 			} else {
 				errs = 1;
-				error("path '%s' is unmerged", ce->name);
+				error(_("path '%s' is unmerged"), ce->name);
 			}
 			pos = skip_same_name(ce, pos) - 1;
 		}
@@ -277,7 +277,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
 
 	if (write_cache(newfd, active_cache, active_nr) ||
 	    commit_locked_index(lock_file))
-		die("unable to write new index file");
+		die(_("unable to write new index file"));
 
 	resolve_ref("HEAD", rev, 0, &flag);
 	head = lookup_commit_reference_gently(rev, 1);
@@ -294,7 +294,7 @@ static void show_local_changes(struct object *head, struct diff_options *opts)
 	rev.diffopt.flags = opts->flags;
 	rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
 	if (diff_setup_done(&rev.diffopt) < 0)
-		die("diff_setup_done failed");
+		die(_("diff_setup_done failed"));
 	add_pending_object(&rev, head, NULL);
 	run_diff_index(&rev, 0);
 }
@@ -368,7 +368,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 	int newfd = hold_locked_index(lock_file, 1);
 
 	if (read_cache_preload(NULL) < 0)
-		return error("corrupt index file");
+		return error(_("corrupt index file"));
 
 	resolve_undo_clear();
 	if (opts->force) {
@@ -390,7 +390,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 		refresh_cache(REFRESH_QUIET);
 
 		if (unmerged_cache()) {
-			error("you need to resolve your current index first");
+			error(_("you need to resolve your current index first"));
 			return 1;
 		}
 
@@ -475,7 +475,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 
 	if (write_cache(newfd, active_cache, active_nr) ||
 	    commit_locked_index(lock_file))
-		die("unable to write new index file");
+		die(_("unable to write new index file"));
 
 	if (!opts->force && !opts->quiet)
 		show_local_changes(&new->commit->object, &opts->diff_options);
@@ -524,7 +524,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 				temp = log_all_ref_updates;
 				log_all_ref_updates = 1;
 				if (log_ref_setup(ref_name, log_file, sizeof(log_file))) {
-					fprintf(stderr, "Can not do reflog for '%s'\n",
+					fprintf(stderr, _("Can not do reflog for '%s'\n"),
 					    opts->new_orphan_branch);
 					log_all_ref_updates = temp;
 					return;
@@ -550,14 +550,14 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 		create_symref("HEAD", new->path, msg.buf);
 		if (!opts->quiet) {
 			if (old->path && !strcmp(new->path, old->path))
-				fprintf(stderr, "Already on '%s'\n",
+				fprintf(stderr, _("Already on '%s'\n"),
 					new->name);
 			else if (opts->new_branch)
 				fprintf(stderr, "Switched to%s branch '%s'\n",
 					opts->branch_exists ? " and reset" : " a new",
 					new->name);
 			else
-				fprintf(stderr, "Switched to branch '%s'\n",
+				fprintf(stderr, _("Switched to branch '%s'\n"),
 					new->name);
 		}
 		if (old->path && old->name) {
@@ -602,7 +602,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
 		new->name = "HEAD";
 		new->commit = old.commit;
 		if (!new->commit)
-			die("You are on a branch yet to be born");
+			die(_("You are on a branch yet to be born"));
 		parse_commit(new->commit);
 	}
 
@@ -731,7 +731,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
 	/* we can assume from now on new_branch = !new_branch_force */
 	if (opts.new_branch && opts.new_branch_force)
-		die("-B cannot be used with -b");
+		die(_("-B cannot be used with -b"));
 
 	/* copy -B over to -b, so that we can just check the latter */
 	if (opts.new_branch_force)
@@ -739,28 +739,28 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
 	if (patch_mode && (opts.track > 0 || opts.new_branch
 			   || opts.new_branch_log || opts.merge || opts.force))
-		die ("--patch is incompatible with all other options");
+		die (_("--patch is incompatible with all other options"));
 
 	/* --track without -b should DWIM */
 	if (0 < opts.track && !opts.new_branch) {
 		const char *argv0 = argv[0];
 		if (!argc || !strcmp(argv0, "--"))
-			die ("--track needs a branch name");
+			die (_("--track needs a branch name"));
 		if (!prefixcmp(argv0, "refs/"))
 			argv0 += 5;
 		if (!prefixcmp(argv0, "remotes/"))
 			argv0 += 8;
 		argv0 = strchr(argv0, '/');
 		if (!argv0 || !argv0[1])
-			die ("Missing branch name; try -b");
+			die (_("Missing branch name; try -b"));
 		opts.new_branch = argv0 + 1;
 	}
 
 	if (opts.new_orphan_branch) {
 		if (opts.new_branch)
-			die("--orphan and -b|-B are mutually exclusive");
+			die(_("--orphan and -b|-B are mutually exclusive"));
 		if (opts.track > 0)
-			die("--orphan cannot be used with -t");
+			die(_("--orphan cannot be used with -t"));
 		opts.new_branch = opts.new_orphan_branch;
 	}
 
@@ -770,7 +770,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	}
 
 	if (opts.force && opts.merge)
-		die("git checkout: -f and -m are incompatible");
+		die(_("git checkout: -f and -m are incompatible"));
 
 	/*
 	 * case 1: git checkout <ref> -- [<paths>]
@@ -816,7 +816,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
 		if (get_sha1_mb(arg, rev)) {
 			if (has_dash_dash)          /* case (1) */
-				die("invalid reference: %s", arg);
+				die(_("invalid reference: %s"), arg);
 			if (!patch_mode &&
 			    dwim_new_local_branch &&
 			    opts.track == BRANCH_TRACK_UNSPECIFIED &&
@@ -853,7 +853,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 			source_tree = parse_tree_indirect(rev);
 
 		if (!source_tree)                   /* case (1): want a tree */
-			die("reference is not a tree: %s", arg);
+			die(_("reference is not a tree: %s"), arg);
 		if (!has_dash_dash) {/* case (3 -> 1) */
 			/*
 			 * Do not complain the most common case
@@ -879,7 +879,7 @@ no_reference:
 		const char **pathspec = get_pathspec(prefix, argv);
 
 		if (!pathspec)
-			die("invalid path specification");
+			die(_("invalid path specification"));
 
 		if (patch_mode)
 			return interactive_checkout(new.name, pathspec, &opts);
@@ -887,14 +887,14 @@ no_reference:
 		/* Checkout paths */
 		if (opts.new_branch) {
 			if (argc == 1) {
-				die("git checkout: updating paths is incompatible with switching branches.\nDid you intend to checkout '%s' which can not be resolved as commit?", argv[0]);
+				die(_("git checkout: updating paths is incompatible with switching branches.\nDid you intend to checkout '%s' which can not be resolved as commit?"), argv[0]);
 			} else {
-				die("git checkout: updating paths is incompatible with switching branches.");
+				die(_("git checkout: updating paths is incompatible with switching branches."));
 			}
 		}
 
 		if (1 < !!opts.writeout_stage + !!opts.force + !!opts.merge)
-			die("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index.");
+			die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index."));
 
 		return checkout_paths(source_tree, pathspec, &opts);
 	}
@@ -905,22 +905,22 @@ no_reference:
 	if (opts.new_branch) {
 		struct strbuf buf = STRBUF_INIT;
 		if (strbuf_check_branch_ref(&buf, opts.new_branch))
-			die("git checkout: we do not like '%s' as a branch name.",
+			die(_("git checkout: we do not like '%s' as a branch name."),
 			    opts.new_branch);
 		if (!get_sha1(buf.buf, rev)) {
 			opts.branch_exists = 1;
 			if (!opts.new_branch_force)
-				die("git checkout: branch %s already exists",
+				die(_("git checkout: branch %s already exists"),
 				    opts.new_branch);
 		}
 		strbuf_release(&buf);
 	}
 
 	if (new.name && !new.commit) {
-		die("Cannot switch branch to a non-commit.");
+		die(_("Cannot switch branch to a non-commit."));
 	}
 	if (opts.writeout_stage)
-		die("--ours/--theirs is incompatible with switching branches.");
+		die(_("--ours/--theirs is incompatible with switching branches."));
 
 	return switch_branches(&opts, &new);
 }
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 12/13] gettextize: git-checkout describe_detached_head messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

This is comparable to the basic messages, but I put it in its own patch mainly as a reminder to myself, this maybe needs to be split into a %s format in the future.

 builtin/checkout.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to builtin/checkout.c +2 −2
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a7033a0..79cbcef 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -574,7 +574,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 		if (!opts->quiet) {
 			if (old->path && advice_detached_head)
 				detach_advice(old->path, new->name);
-			describe_detached_head("HEAD is now at", new->commit);
+			describe_detached_head(_("HEAD is now at"), new->commit);
 		}
 	}
 	remove_branch_state();
@@ -616,7 +616,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
 	 * to remind the user that it might be lost.
 	 */
 	if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
-		describe_detached_head("Previous HEAD position was", old.commit);
+		describe_detached_head(_("Previous HEAD position was"), old.commit);
 
 	update_refs_for_switch(opts, &old, new);
 
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 1, 2010, 20:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 13/13] gettextize: git-checkout "Switched to a .. branch" message

Split up the "Switched to and reset branch" and "Switched to a new branch" messages to make them easier to translate.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/checkout.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
Show changes to builtin/checkout.c +4 −3
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 79cbcef..8d8649a 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -553,9 +553,10 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 				fprintf(stderr, _("Already on '%s'\n"),
 					new->name);
 			else if (opts->new_branch)
-				fprintf(stderr, "Switched to%s branch '%s'\n",
-					opts->branch_exists ? " and reset" : " a new",
-					new->name);
+				if (opts->branch_exists)
+					fprintf(stderr, _("Switched to and reset branch '%s'\n"), new->name);
+				else
+					fprintf(stderr, _("Switched to a new branch '%s'\n"), new->name);
 			else
 				fprintf(stderr, _("Switched to branch '%s'\n"),
 					new->name);
-- 
1.7.2.2.579.g2183d
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 00/25] [CONTINUED] gettextize all C mainporcelain common commands

This series continues where "gettextize the first 4 C mainporcelain common commands" left off and translates all the C mainporcelain common commands (the only non-C ones left are bisect/pull/rebase).

With this Git is up to 482 translatable messages.

For reviewing all the patches that say "basic messages" were (mostly) converted by an automated script and should be really straightforward. Most of these are just plain die/error/printf calls with a single message.

See further comments on individual patches below. Most comment only apply to the patch immediately above them.

Ævar Arnfjörð Bjarmason (25):
  gettextize: git-commit basic messages
  gettextize: git-commit formatting messages
The message you get in the editor with git add . && git-commit
  gettextize: git-commit advice messages
An example of N_() and _() usage.
  gettextize: git-diff basic messages
  gettextize: git-fetch basic messages
  gettextize: git-fetch formatting messages

The status output you get on "git fetch" where it's telling you what changed.

  gettextize: git-grep basic messages
  gettextize: git-log basic messages
This is more than just git-log actually, e.g. git-show too.
  gettextize: git-format-patch --cover-letter message
I think this should be made translatable.
  gettextize: git-merge basic messages

This need careful review. In many cases git-merge is writing out to some .git/* file and I *don't* want to translate that, but it could use a second set of eyes to see if I missed something.

  gettextize: git-merge "In-index merge" message
  gettextize: git-merge "Merge made by %s." message
  gettextize: git-merge remaining cmd_merge messages
These I reviewed carefully and they should be trivial.
  gettextize: git-mv basic messages
  gettextize: git-mv "bad" messages
  gettextize: git-rm basic messages
ditto, these should all be fine.
  builtin: use builtin.h in git-reset

as before, this is not needed if "builtin: use builtin.h for all builtin/ commands" is applied. But it's here for convenience. If the previously submitted builtin.h patch is applied this can be dropped.

  gettextize: git-reset basic messages
  gettextize: git-reset reset_type_names messages
Another N_() and _() patch.
  gettextize: git-tag basic messages
  gettextize: git-tag tag_template message
Another N_() and _() patch.
  gettextize: git-push basic messages
  builtin: use builtin.h in git-status

This is *not* in my previously submitted "builtin: use builtin.h for all builtin/ commands" patch.

  gettextize: git-status basic messages
An old resurrected patch ...
  gettextize: git-status shortstatus messages
... but wt-status changed since then, so this was needed too.
 builtin/commit.c |  156 +++++++++++++++++++++++++++---------------------------
 builtin/diff.c   |   20 ++++----
 builtin/fetch.c  |   74 +++++++++++++-------------
 builtin/grep.c   |   34 ++++++------
 builtin/log.c    |   76 +++++++++++++-------------
 builtin/merge.c  |  136 +++++++++++++++++++++++-----------------------
 builtin/mv.c     |   32 ++++++------
 builtin/push.c   |   42 +++++++-------
 builtin/reset.c  |   44 ++++++++--------
 builtin/rm.c     |   22 ++++----
 builtin/tag.c    |   66 +++++++++++-----------
 wt-status.c      |  115 ++++++++++++++++++++--------------------
 12 files changed, 409 insertions(+), 408 deletions(-)
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 01/25] gettextize: git-commit basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit.c |  116 +++++++++++++++++++++++++++---------------------------
 1 files changed, 58 insertions(+), 58 deletions(-)
Show changes to builtin/commit.c +58 −58
diff --git a/builtin/commit.c b/builtin/commit.c
index 66fdd22..cabf6e3 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -241,7 +241,7 @@ static void add_remove_files(struct string_list *list)
 
 		if (!lstat(p->string, &st)) {
 			if (add_to_cache(p->string, &st, 0))
-				die("updating files failed");
+				die(_("updating files failed"));
 		} else
 			remove_file_from_cache(p->string);
 	}
@@ -268,7 +268,7 @@ static void create_base_index(void)
 	opts.fn = oneway_merge;
 	tree = parse_tree_indirect(head_sha1);
 	if (!tree)
-		die("failed to unpack HEAD tree object");
+		die(_("failed to unpack HEAD tree object"));
 	parse_tree(tree);
 	init_tree_desc(&t, tree->buffer, tree->size);
 	if (unpack_trees(1, &t, &opts))
@@ -296,9 +296,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 		refresh_flags |= REFRESH_UNMERGED;
 	if (interactive) {
 		if (interactive_add(argc, argv, prefix) != 0)
-			die("interactive add failed");
+			die(_("interactive add failed"));
 		if (read_cache_preload(NULL) < 0)
-			die("index file corrupt");
+			die(_("index file corrupt"));
 		commit_style = COMMIT_AS_IS;
 		return get_index_file();
 	}
@@ -307,7 +307,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 		pathspec = get_pathspec(prefix, argv);
 
 	if (read_cache_preload(pathspec) < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 
 	/*
 	 * Non partial, non as-is commit.
@@ -327,7 +327,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 		refresh_cache_or_die(refresh_flags);
 		if (write_cache(fd, active_cache, active_nr) ||
 		    close_lock_file(&index_lock))
-			die("unable to write new_index file");
+			die(_("unable to write new_index file"));
 		commit_style = COMMIT_NORMAL;
 		return index_lock.filename;
 	}
@@ -347,7 +347,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 		if (active_cache_changed) {
 			if (write_cache(fd, active_cache, active_nr) ||
 			    commit_locked_index(&index_lock))
-				die("unable to write new_index file");
+				die(_("unable to write new_index file"));
 		} else {
 			rollback_lock_file(&index_lock);
 		}
@@ -377,7 +377,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 	commit_style = COMMIT_PARTIAL;
 
 	if (in_merge)
-		die("cannot do a partial commit during a merge.");
+		die(_("cannot do a partial commit during a merge."));
 
 	memset(&partial, 0, sizeof(partial));
 	partial.strdup_strings = 1;
@@ -386,14 +386,14 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 
 	discard_cache();
 	if (read_cache() < 0)
-		die("cannot read the index");
+		die(_("cannot read the index"));
 
 	fd = hold_locked_index(&index_lock, 1);
 	add_remove_files(&partial);
 	refresh_cache(REFRESH_QUIET);
 	if (write_cache(fd, active_cache, active_nr) ||
 	    close_lock_file(&index_lock))
-		die("unable to write new_index file");
+		die(_("unable to write new_index file"));
 
 	fd = hold_lock_file_for_update(&false_lock,
 				       git_path("next-index-%"PRIuMAX,
@@ -406,7 +406,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 
 	if (write_cache(fd, active_cache, active_nr) ||
 	    close_lock_file(&false_lock))
-		die("unable to write temporary index file");
+		die(_("unable to write temporary index file"));
 
 	discard_cache();
 	read_cache_from(false_lock.filename);
@@ -453,7 +453,7 @@ static int is_a_merge(const unsigned char *sha1)
 {
 	struct commit *commit = lookup_commit(sha1);
 	if (!commit || parse_commit(commit))
-		die("could not parse HEAD commit");
+		die(_("could not parse HEAD commit"));
 	return !!(commit->parents && commit->parents->next);
 }
 
@@ -472,13 +472,13 @@ static void determine_author_info(void)
 
 		a = strstr(use_message_buffer, "\nauthor ");
 		if (!a)
-			die("invalid commit: %s", use_message);
+			die(_("invalid commit: %s"), use_message);
 
 		lb = strchrnul(a + strlen("\nauthor "), '<');
 		rb = strchrnul(lb, '>');
 		eol = strchrnul(rb, '\n');
 		if (!*lb || !*rb || !*eol)
-			die("invalid commit: %s", use_message);
+			die(_("invalid commit: %s"), use_message);
 
 		if (lb == a + strlen("\nauthor "))
 			/* \nauthor <foo@example.com> */
@@ -496,7 +496,7 @@ static void determine_author_info(void)
 		const char *rb = strchr(force_author, '>');
 
 		if (!lb || !rb)
-			die("malformed --author parameter");
+			die(_("malformed --author parameter"));
 		name = xstrndup(force_author, lb - force_author);
 		email = xstrndup(lb + 2, rb - (lb + 2));
 	}
@@ -570,33 +570,33 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		hook_arg1 = "message";
 	} else if (logfile && !strcmp(logfile, "-")) {
 		if (isatty(0))
-			fprintf(stderr, "(reading log message from standard input)\n");
+			fprintf(stderr, _("(reading log message from standard input)\n"));
 		if (strbuf_read(&sb, 0, 0) < 0)
-			die_errno("could not read log from standard input");
+			die_errno(_("could not read log from standard input"));
 		hook_arg1 = "message";
 	} else if (logfile) {
 		if (strbuf_read_file(&sb, logfile, 0) < 0)
-			die_errno("could not read log file '%s'",
+			die_errno(_("could not read log file '%s'"),
 				  logfile);
 		hook_arg1 = "message";
 	} else if (use_message) {
 		buffer = strstr(use_message_buffer, "\n\n");
 		if (!buffer || buffer[2] == '\0')
-			die("commit has empty message");
+			die(_("commit has empty message"));
 		strbuf_add(&sb, buffer + 2, strlen(buffer + 2));
 		hook_arg1 = "commit";
 		hook_arg2 = use_message;
 	} else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
 		if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)
-			die_errno("could not read MERGE_MSG");
+			die_errno(_("could not read MERGE_MSG"));
 		hook_arg1 = "merge";
 	} else if (!stat(git_path("SQUASH_MSG"), &statbuf)) {
 		if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
-			die_errno("could not read SQUASH_MSG");
+			die_errno(_("could not read SQUASH_MSG"));
 		hook_arg1 = "squash";
 	} else if (template_file && !stat(template_file, &statbuf)) {
 		if (strbuf_read_file(&sb, template_file, 0) < 0)
-			die_errno("could not read '%s'", template_file);
+			die_errno(_("could not read '%s'"), template_file);
 		hook_arg1 = "template";
 	}
 
@@ -609,7 +609,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 
 	fp = fopen(git_path(commit_editmsg), "w");
 	if (fp == NULL)
-		die_errno("could not open '%s'", git_path(commit_editmsg));
+		die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
 	if (cleanup_mode != CLEANUP_NONE)
 		stripspace(&sb, 0);
@@ -633,7 +633,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	}
 
 	if (fwrite(sb.buf, 1, sb.len, fp) < sb.len)
-		die_errno("could not write commit template");
+		die_errno(_("could not write commit template"));
 
 	strbuf_release(&sb);
 
@@ -702,7 +702,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		const char *parent = "HEAD";
 
 		if (!active_nr && read_cache() < 0)
-			die("Cannot read index");
+			die(_("Cannot read index"));
 
 		if (amend)
 			parent = "HEAD^1";
@@ -734,7 +734,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		active_cache_tree = cache_tree();
 	if (cache_tree_update(active_cache_tree,
 			      active_cache, active_nr, 0, 0) < 0) {
-		error("Error building trees");
+		error(_("Error building trees"));
 		return 0;
 	}
 
@@ -749,7 +749,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
 		if (launch_editor(git_path(commit_editmsg), NULL, env)) {
 			fprintf(stderr,
-			"Please supply the message using either -m or -F option.\n");
+			_("Please supply the message using either -m or -F option.\n"));
 			exit(1);
 		}
 	}
@@ -829,7 +829,7 @@ static const char *find_author_by_nickname(const char *name)
 		format_commit_message(commit, "%an <%ae>", &buf, &ctx);
 		return strbuf_detach(&buf, NULL);
 	}
-	die("No existing author found with '%s'", name);
+	die(_("No existing author found with '%s'"), name);
 }
 
 
@@ -844,7 +844,7 @@ static void handle_untracked_files_arg(struct wt_status *s)
 	else if (!strcmp(untracked_files_arg, "all"))
 		s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
 	else
-		die("Invalid untracked files mode '%s'", untracked_files_arg);
+		die(_("Invalid untracked files mode '%s'"), untracked_files_arg);
 }
 
 static int parse_and_validate_options(int argc, const char *argv[],
@@ -861,7 +861,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
 		force_author = find_author_by_nickname(force_author);
 
 	if (force_author && renew_authorship)
-		die("Using both --reset-author and --author does not make sense");
+		die(_("Using both --reset-author and --author does not make sense"));
 
 	if (logfile || message.len || use_message)
 		use_editor = 0;
@@ -875,9 +875,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
 
 	/* Sanity check options */
 	if (amend && initial_commit)
-		die("You have nothing to amend.");
+		die(_("You have nothing to amend."));
 	if (amend && in_merge)
-		die("You are in the middle of a merge -- cannot amend.");
+		die(_("You are in the middle of a merge -- cannot amend."));
 
 	if (use_message)
 		f++;
@@ -886,15 +886,15 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	if (logfile)
 		f++;
 	if (f > 1)
-		die("Only one of -c/-C/-F can be used.");
+		die(_("Only one of -c/-C/-F can be used."));
 	if (message.len && f > 0)
-		die("Option -m cannot be combined with -c/-C/-F.");
+		die(_("Option -m cannot be combined with -c/-C/-F."));
 	if (edit_message)
 		use_message = edit_message;
 	if (amend && !use_message)
 		use_message = "HEAD";
 	if (!use_message && renew_authorship)
-		die("--reset-author can be used only with -C, -c or --amend.");
+		die(_("--reset-author can be used only with -C, -c or --amend."));
 	if (use_message) {
 		unsigned char sha1[20];
 		static char utf8[] = "UTF-8";
@@ -903,10 +903,10 @@ static int parse_and_validate_options(int argc, const char *argv[],
 		struct commit *commit;
 
 		if (get_sha1(use_message, sha1))
-			die("could not lookup commit %s", use_message);
+			die(_("could not lookup commit %s"), use_message);
 		commit = lookup_commit_reference(sha1);
 		if (!commit || parse_commit(commit))
-			die("could not parse commit %s", use_message);
+			die(_("could not parse commit %s"), use_message);
 
 		enc = strstr(commit->buffer, "\nencoding");
 		if (enc) {
@@ -934,13 +934,13 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	}
 
 	if (!!also + !!only + !!all + !!interactive > 1)
-		die("Only one of --include/--only/--all/--interactive can be used.");
+		die(_("Only one of --include/--only/--all/--interactive can be used."));
 	if (argc == 0 && (also || (only && !amend)))
-		die("No paths with --include/--only does not make sense.");
+		die(_("No paths with --include/--only does not make sense."));
 	if (argc == 0 && only && amend)
-		only_include_assumed = "Clever... amending the last one with dirty index.";
+		only_include_assumed = _("Clever... amending the last one with dirty index.");
 	if (argc > 0 && !also && !only)
-		only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
+		only_include_assumed = _("Explicit paths specified without -i nor -o; assuming --only paths...");
 	if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
 		cleanup_mode = use_editor ? CLEANUP_ALL : CLEANUP_SPACE;
 	else if (!strcmp(cleanup_arg, "verbatim"))
@@ -950,14 +950,14 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	else if (!strcmp(cleanup_arg, "strip"))
 		cleanup_mode = CLEANUP_ALL;
 	else
-		die("Invalid cleanup mode %s", cleanup_arg);
+		die(_("Invalid cleanup mode %s"), cleanup_arg);
 
 	handle_untracked_files_arg(s);
 
 	if (all && argc > 0)
-		die("Paths with -a does not make sense.");
+		die(_("Paths with -a does not make sense."));
 	else if (interactive && argc > 0)
-		die("Paths with --interactive does not make sense.");
+		die(_("Paths with --interactive does not make sense."));
 
 	if (null_termination && status_format == STATUS_FORMAT_LONG)
 		status_format = STATUS_FORMAT_PORCELAIN;
@@ -1036,7 +1036,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
 		else if (!strcmp(v, "all"))
 			s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
 		else
-			return error("Invalid untracked files mode '%s'", v);
+			return error(_("Invalid untracked files mode '%s'"), v);
 		return 0;
 	}
 	return git_diff_ui_config(k, v, NULL);
@@ -1139,9 +1139,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 
 	commit = lookup_commit(sha1);
 	if (!commit)
-		die("couldn't look up newly created commit");
+		die(_("couldn't look up newly created commit"));
 	if (!commit || parse_commit(commit))
-		die("could not parse newly created commit");
+		die(_("could not parse newly created commit"));
 
 	strbuf_addstr(&format, "format:%h] %s");
 
@@ -1291,7 +1291,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 			reflog_msg = "commit (amend)";
 		commit = lookup_commit(head_sha1);
 		if (!commit || parse_commit(commit))
-			die("could not parse HEAD commit");
+			die(_("could not parse HEAD commit"));
 
 		for (c = commit->parents; c; c = c->next)
 			pptr = &commit_list_insert(c->item, pptr)->next;
@@ -1304,19 +1304,19 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
 		fp = fopen(git_path("MERGE_HEAD"), "r");
 		if (fp == NULL)
-			die_errno("could not open '%s' for reading",
+			die_errno(_("could not open '%s' for reading"),
 				  git_path("MERGE_HEAD"));
 		while (strbuf_getline(&m, fp, '\n') != EOF) {
 			unsigned char sha1[20];
 			if (get_sha1_hex(m.buf, sha1) < 0)
-				die("Corrupt MERGE_HEAD file (%s)", m.buf);
+				die(_("Corrupt MERGE_HEAD file (%s)"), m.buf);
 			pptr = &commit_list_insert(lookup_commit(sha1), pptr)->next;
 		}
 		fclose(fp);
 		strbuf_release(&m);
 		if (!stat(git_path("MERGE_MODE"), &statbuf)) {
 			if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
-				die_errno("could not read MERGE_MODE");
+				die_errno(_("could not read MERGE_MODE"));
 			if (!strcmp(sb.buf, "no-ff"))
 				allow_fast_forward = 0;
 		}
@@ -1333,7 +1333,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
 		int saved_errno = errno;
 		rollback_index_files();
-		die("could not read commit message: %s", strerror(saved_errno));
+		die(_("could not read commit message: %s"), strerror(saved_errno));
 	}
 
 	/* Truncate the message just before the diff, if any. */
@@ -1347,7 +1347,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		stripspace(&sb, cleanup_mode == CLEANUP_ALL);
 	if (message_is_empty(&sb) && !allow_empty_message) {
 		rollback_index_files();
-		fprintf(stderr, "Aborting commit due to empty commit message.\n");
+		fprintf(stderr, _("Aborting commit due to empty commit message.\n"));
 		exit(1);
 	}
 
@@ -1355,7 +1355,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 			fmt_ident(author_name, author_email, author_date,
 				IDENT_ERROR_ON_NO_NAME))) {
 		rollback_index_files();
-		die("failed to write commit object");
+		die(_("failed to write commit object"));
 	}
 
 	ref_lock = lock_any_ref_for_update("HEAD",
@@ -1372,11 +1372,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 	if (!ref_lock) {
 		rollback_index_files();
-		die("cannot lock HEAD ref");
+		die(_("cannot lock HEAD ref"));
 	}
 	if (write_ref_sha1(ref_lock, commit_sha1, sb.buf) < 0) {
 		rollback_index_files();
-		die("cannot update HEAD ref");
+		die(_("cannot update HEAD ref"));
 	}
 
 	unlink(git_path("MERGE_HEAD"));
@@ -1385,9 +1385,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	unlink(git_path("SQUASH_MSG"));
 
 	if (commit_index_files())
-		die ("Repository has been updated, but unable to write\n"
+		die (_("Repository has been updated, but unable to write\n"
 		     "new_index file. Check that disk is not full or quota is\n"
-		     "not exceeded, and then \"git reset HEAD\" to recover.");
+		     "not exceeded, and then \"git reset HEAD\" to recover."));
 
 	rerere(0);
 	run_hook(get_index_file(), "post-commit", NULL);
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 02/25] gettextize: git-commit formatting messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
Show changes to builtin/commit.c +14 −14
diff --git a/builtin/commit.c b/builtin/commit.c
index cabf6e3..3fd479d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -647,28 +647,28 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 
 		if (in_merge)
 			fprintf(fp,
-				"#\n"
+				_("#\n"
 				"# It looks like you may be committing a MERGE.\n"
 				"# If this is not correct, please remove the file\n"
 				"#	%s\n"
 				"# and try again.\n"
-				"#\n",
+				"#\n"),
 				git_path("MERGE_HEAD"));
 
 		fprintf(fp,
-			"\n"
-			"# Please enter the commit message for your changes.");
+			_("\n"
+			"# Please enter the commit message for your changes."));
 		if (cleanup_mode == CLEANUP_ALL)
 			fprintf(fp,
-				" Lines starting\n"
+				_(" Lines starting\n"
 				"# with '#' will be ignored, and an empty"
-				" message aborts the commit.\n");
+				" message aborts the commit.\n"));
 		else /* CLEANUP_SPACE, that is. */
 			fprintf(fp,
-				" Lines starting\n"
+				_(" Lines starting\n"
 				"# with '#' will be kept; you may remove them"
 				" yourself if you want to.\n"
-				"# An empty message aborts the commit.\n");
+				"# An empty message aborts the commit.\n"));
 		if (only_include_assumed)
 			fprintf(fp, "# %s\n", only_include_assumed);
 
@@ -677,16 +677,16 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 					   getenv("GIT_COMMITTER_EMAIL"));
 		if (strcmp(author_ident, committer_ident))
 			fprintf(fp,
-				"%s"
-				"# Author:    %s\n",
+				_("%s"
+				"# Author:    %s\n"),
 				ident_shown++ ? "" : "#\n",
 				author_ident);
 		free(author_ident);
 
 		if (!user_ident_sufficiently_given())
 			fprintf(fp,
-				"%s"
-				"# Committer: %s\n",
+				_("%s"
+				"# Committer: %s\n"),
 				ident_shown++ ? "" : "#\n",
 				committer_ident);
 
@@ -1182,9 +1182,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 		!prefixcmp(head, "refs/heads/") ?
 			head + 11 :
 			!strcmp(head, "HEAD") ?
-				"detached HEAD" :
+		   		_("detached HEAD") :
 				head,
-		initial_commit ? " (root-commit)" : "");
+		initial_commit ? _(" (root-commit)") : "");
 
 	if (!log_tree_commit(&rev, commit)) {
 		rev.always_show_header = 1;
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 03/25] gettextize: git-commit advice messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Show changes to builtin/commit.c +6 −6
diff --git a/builtin/commit.c b/builtin/commit.c
index 3fd479d..3626a8d 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -38,7 +38,7 @@ static const char * const builtin_status_usage[] = {
 };
 
 static const char implicit_ident_advice[] =
-"Your name and email address were configured automatically based\n"
+N_("Your name and email address were configured automatically based\n"
 "on your username and hostname. Please check that they are accurate.\n"
 "You can suppress this message by setting them explicitly:\n"
 "\n"
@@ -47,12 +47,12 @@ static const char implicit_ident_advice[] =
 "\n"
 "If the identity used for this commit is wrong, you can fix it with:\n"
 "\n"
-"    git commit --amend --author='Your Name <you@example.com>'\n";
+"    git commit --amend --author='Your Name <you@example.com>'\n");
 
 static const char empty_amend_advice[] =
-"You asked to amend the most recent commit, but doing so would make\n"
+N_("You asked to amend the most recent commit, but doing so would make\n"
 "it empty. You can repeat your command with --allow-empty, or you can\n"
-"remove the commit entirely with \"git reset HEAD^\".\n";
+"remove the commit entirely with \"git reset HEAD^\".\n");
 
 static unsigned char head_sha1[20];
 
@@ -719,7 +719,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	    !(amend && is_a_merge(head_sha1))) {
 		run_status(stdout, index_file, prefix, 0, s);
 		if (amend)
-			fputs(empty_amend_advice, stderr);
+			fputs(_(empty_amend_advice), stderr);
 		return 0;
 	}
 
@@ -1156,7 +1156,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 		strbuf_addbuf_percentquote(&format, &committer_ident);
 		if (advice_implicit_identity) {
 			strbuf_addch(&format, '\n');
-			strbuf_addstr(&format, implicit_ident_advice);
+			strbuf_addstr(&format, _(implicit_ident_advice));
 		}
 	}
 	strbuf_release(&author_ident);
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 04/25] gettextize: git-diff basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/diff.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
Show changes to builtin/diff.c +10 −10
diff --git a/builtin/diff.c b/builtin/diff.c
index a43d326..3ae5715 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -71,9 +71,9 @@ static int builtin_diff_b_f(struct rev_info *revs,
 		usage(builtin_diff_usage);
 
 	if (lstat(path, &st))
-		die_errno("failed to stat '%s'", path);
+		die_errno(_("failed to stat '%s'"), path);
 	if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
-		die("'%s': not a regular file or symlink", path);
+		die(_("'%s': not a regular file or symlink"), path);
 
 	diff_set_mnemonic_prefix(&revs->diffopt, "o/", "w/");
 
@@ -222,7 +222,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
 		else if (!strcmp(argv[1], "-h"))
 			usage(builtin_diff_usage);
 		else
-			return error("invalid option: %s", argv[1]);
+			return error(_("invalid option: %s"), argv[1]);
 		argv++; argc--;
 	}
 
@@ -299,12 +299,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 	DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
 
 	if (nongit)
-		die("Not a git repository");
+		die(_("Not a git repository"));
 	argc = setup_revisions(argc, argv, &rev, NULL);
 	if (!rev.diffopt.output_format) {
 		rev.diffopt.output_format = DIFF_FORMAT_PATCH;
 		if (diff_setup_done(&rev.diffopt) < 0)
-			die("diff_setup_done failed");
+			die(_("diff_setup_done failed"));
 	}
 
 	DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
@@ -331,7 +331,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 				 !strcmp(arg, "--staged")) {
 				add_head_to_pending(&rev);
 				if (!rev.pending.nr)
-					die("No HEAD commit to compare with (yet)");
+					die(_("No HEAD commit to compare with (yet)"));
 				break;
 			}
 		}
@@ -346,12 +346,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 			obj = parse_object(obj->sha1);
 		obj = deref_tag(obj, NULL, 0);
 		if (!obj)
-			die("invalid object '%s' given.", name);
+			die(_("invalid object '%s' given."), name);
 		if (obj->type == OBJ_COMMIT)
 			obj = &((struct commit *)obj)->tree->object;
 		if (obj->type == OBJ_TREE) {
 			if (ARRAY_SIZE(ent) <= ents)
-				die("more than %d trees given: '%s'",
+				die(_("more than %d trees given: '%s'"),
 				    (int) ARRAY_SIZE(ent), name);
 			obj->flags |= flags;
 			ent[ents].item = obj;
@@ -361,7 +361,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 		}
 		if (obj->type == OBJ_BLOB) {
 			if (2 <= blobs)
-				die("more than two blobs given: '%s'", name);
+				die(_("more than two blobs given: '%s'"), name);
 			hashcpy(blob[blobs].sha1, obj->sha1);
 			blob[blobs].name = name;
 			blob[blobs].mode = list->mode;
@@ -369,7 +369,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 			continue;
 
 		}
-		die("unhandled object '%s' given.", name);
+		die(_("unhandled object '%s' given."), name);
 	}
 	if (rev.prune_data) {
 		const char **pathspec = rev.prune_data;
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 05/25] gettextize: git-fetch basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/fetch.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
Show changes to builtin/fetch.c +23 −23
diff --git a/builtin/fetch.c b/builtin/fetch.c
index c218657..4c90fc5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -178,7 +178,7 @@ static struct ref *get_ref_map(struct transport *transport,
 		} else {
 			ref_map = get_remote_ref(remote_refs, "HEAD");
 			if (!ref_map)
-				die("Couldn't find remote ref HEAD");
+				die(_("Couldn't find remote ref HEAD"));
 			ref_map->merge = 1;
 			tail = &ref_map->next;
 		}
@@ -231,7 +231,7 @@ static int update_local_ref(struct ref *ref,
 	*display = 0;
 	type = sha1_object_info(ref->new_sha1, NULL);
 	if (type < 0)
-		die("object %s not found", sha1_to_hex(ref->new_sha1));
+		die(_("object %s not found"), sha1_to_hex(ref->new_sha1));
 
 	if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
 		if (verbosity > 0)
@@ -331,7 +331,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
 	fp = fopen(filename, "a");
 	if (!fp)
-		return error("cannot open %s: %s\n", filename, strerror(errno));
+		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
 
 	if (raw_url)
 		url = transport_anonymize_url(raw_url);
@@ -420,9 +420,9 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 	free(url);
 	fclose(fp);
 	if (rc & STORE_REF_ERROR_DF_CONFLICT)
-		error("some local refs could not be updated; try running\n"
+		error(_("some local refs could not be updated; try running\n"
 		      " 'git remote prune %s' to remove any old, conflicting "
-		      "branches", remote_name);
+		      "branches"), remote_name);
 	return rc;
 }
 
@@ -470,7 +470,7 @@ static int quickfetch(struct ref *ref_map)
 
 	err = start_command(&revlist);
 	if (err) {
-		error("could not run rev-list");
+		error(_("could not run rev-list"));
 		return err;
 	}
 
@@ -484,14 +484,14 @@ static int quickfetch(struct ref *ref_map)
 		if (write_in_full(revlist.in, sha1_to_hex(ref->old_sha1), 40) < 0 ||
 		    write_str_in_full(revlist.in, "\n") < 0) {
 			if (errno != EPIPE && errno != EINVAL)
-				error("failed write to rev-list: %s", strerror(errno));
+				error(_("failed write to rev-list: %s"), strerror(errno));
 			err = -1;
 			break;
 		}
 	}
 
 	if (close(revlist.in)) {
-		error("failed to close rev-list's stdin: %s", strerror(errno));
+		error(_("failed to close rev-list's stdin: %s"), strerror(errno));
 		err = -1;
 	}
 
@@ -644,8 +644,8 @@ static void check_not_current_branch(struct ref *ref_map)
 	for (; ref_map; ref_map = ref_map->next)
 		if (ref_map->peer_ref && !strcmp(current_branch->refname,
 					ref_map->peer_ref->name))
-			die("Refusing to fetch into current branch %s "
-			    "of non-bare repository", current_branch->refname);
+			die(_("Refusing to fetch into current branch %s "
+			    "of non-bare repository"), current_branch->refname);
 }
 
 static int truncate_fetch_head(void)
@@ -654,7 +654,7 @@ static int truncate_fetch_head(void)
 	FILE *fp = fopen(filename, "w");
 
 	if (!fp)
-		return error("cannot open %s: %s\n", filename, strerror(errno));
+		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
 	fclose(fp);
 	return 0;
 }
@@ -678,7 +678,7 @@ static int do_fetch(struct transport *transport,
 	}
 
 	if (!transport->get_refs_list || !transport->fetch)
-		die("Don't know how to fetch from %s", transport->url);
+		die(_("Don't know how to fetch from %s"), transport->url);
 
 	/* if not appending, truncate FETCH_HEAD */
 	if (!append && !dry_run) {
@@ -732,10 +732,10 @@ static void set_option(const char *name, const char *value)
 {
 	int r = transport_set_option(transport, name, value);
 	if (r < 0)
-		die("Option \"%s\" value \"%s\" is not valid for %s",
+		die(_("Option \"%s\" value \"%s\" is not valid for %s"),
 			name, value, transport->url);
 	if (r > 0)
-		warning("Option \"%s\" is ignored for %s\n",
+		warning(_("Option \"%s\" is ignored for %s\n"),
 			name, transport->url);
 }
 
@@ -824,9 +824,9 @@ static int fetch_multiple(struct string_list *list)
 		argv[argc] = name;
 		argv[argc + 1] = NULL;
 		if (verbosity >= 0)
-			printf("Fetching %s\n", name);
+			printf(_("Fetching %s\n"), name);
 		if (run_command_v_opt(argv, RUN_GIT_CMD)) {
-			error("Could not fetch %s", name);
+			error(_("Could not fetch %s"), name);
 			result = 1;
 		}
 	}
@@ -842,8 +842,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
 	int exit_code;
 
 	if (!remote)
-		die("No remote repository specified.  Please, specify either a URL or a\n"
-		    "remote name from which new revisions should be fetched.");
+		die(_("No remote repository specified.  Please, specify either a URL or a\n"
+		    "remote name from which new revisions should be fetched."));
 
 	transport = transport_get(remote, NULL);
 	transport_set_verbosity(transport, verbosity, progress);
@@ -862,7 +862,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
 				char *ref;
 				i++;
 				if (i >= argc)
-					die("You need to specify a tag name.");
+					die(_("You need to specify a tag name."));
 				ref = xmalloc(strlen(argv[i]) * 2 + 22);
 				strcpy(ref, "refs/tags/");
 				strcat(ref, argv[i]);
@@ -902,9 +902,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 
 	if (all) {
 		if (argc == 1)
-			die("fetch --all does not take a repository argument");
+			die(_("fetch --all does not take a repository argument"));
 		else if (argc > 1)
-			die("fetch --all does not make sense with refspecs");
+			die(_("fetch --all does not make sense with refspecs"));
 		(void) for_each_remote(get_one_remote_for_fetch, &list);
 		result = fetch_multiple(&list);
 	} else if (argc == 0) {
@@ -915,7 +915,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 		/* All arguments are assumed to be remotes or groups */
 		for (i = 0; i < argc; i++)
 			if (!add_remote_or_group(argv[i], &list))
-				die("No such remote or remote group: %s", argv[i]);
+				die(_("No such remote or remote group: %s"), argv[i]);
 		result = fetch_multiple(&list);
 	} else {
 		/* Single remote or group */
@@ -923,7 +923,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 		if (list.nr > 1) {
 			/* More than one remote */
 			if (argc > 1)
-				die("Fetching a group and specifying refspecs does not make sense");
+				die(_("Fetching a group and specifying refspecs does not make sense"));
 			result = fetch_multiple(&list);
 		} else {
 			/* Zero or one remotes */
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 06/25] gettextize: git-fetch formatting messages

Translate some of the formatting messages that appear on git-fetch showing how branches/tags etc. were updated.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/fetch.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
Show changes to builtin/fetch.c +14 −14
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 4c90fc5..38bb51d 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -236,7 +236,7 @@ static int update_local_ref(struct ref *ref,
 	if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
 		if (verbosity > 0)
 			sprintf(display, "= %-*s %-*s -> %s", TRANSPORT_SUMMARY_WIDTH,
-				"[up to date]", REFCOL_WIDTH, remote,
+				_("[up to date]"), REFCOL_WIDTH, remote,
 				pretty_ref);
 		return 0;
 	}
@@ -249,8 +249,8 @@ static int update_local_ref(struct ref *ref,
 		 * If this is the head, and it's not okay to update
 		 * the head, and the old value of the head isn't empty...
 		 */
-		sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
-			TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
+		sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
+			TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
 			pretty_ref);
 		return 1;
 	}
@@ -260,8 +260,8 @@ static int update_local_ref(struct ref *ref,
 		int r;
 		r = s_update_ref("updating tag", ref, 0);
 		sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
-			TRANSPORT_SUMMARY_WIDTH, "[tag update]", REFCOL_WIDTH, remote,
-			pretty_ref, r ? "  (unable to update local ref)" : "");
+			TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), REFCOL_WIDTH, remote,
+			pretty_ref, r ? _("  (unable to update local ref)") : "");
 		return r;
 	}
 
@@ -357,15 +357,15 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 			what = "";
 		}
 		else if (!prefixcmp(rm->name, "refs/heads/")) {
-			kind = "branch";
+			kind = _("branch");
 			what = rm->name + 11;
 		}
 		else if (!prefixcmp(rm->name, "refs/tags/")) {
-			kind = "tag";
+			kind = _("tag");
 			what = rm->name + 10;
 		}
 		else if (!prefixcmp(rm->name, "refs/remotes/")) {
-			kind = "remote branch";
+			kind = _("remote branch");
 			what = rm->name + 13;
 		}
 		else {
@@ -405,11 +405,11 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 			free(ref);
 		} else
 			sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
-				TRANSPORT_SUMMARY_WIDTH, *kind ? kind : "branch",
+				TRANSPORT_SUMMARY_WIDTH, *kind ? kind : _("branch"),
 				 REFCOL_WIDTH, *what ? what : "HEAD");
 		if (*note) {
 			if (verbosity >= 0 && !shown_url) {
-				fprintf(stderr, "From %.*s\n",
+				fprintf(stderr, _("From %.*s\n"),
 						url_len, url);
 				shown_url = 1;
 			}
@@ -518,16 +518,16 @@ static int prune_refs(struct transport *transport, struct ref *ref_map)
 	int result = 0;
 	struct ref *ref, *stale_refs = get_stale_heads(transport->remote, ref_map);
 	const char *dangling_msg = dry_run
-		? "   (%s will become dangling)\n"
-		: "   (%s has become dangling)\n";
+		? _("   (%s will become dangling)\n")
+		: _("   (%s has become dangling)\n");
 
 	for (ref = stale_refs; ref; ref = ref->next) {
 		if (!dry_run)
 			result |= delete_ref(ref->name, NULL, 0);
 		if (verbosity >= 0) {
 			fprintf(stderr, " x %-*s %-*s -> %s\n",
-				TRANSPORT_SUMMARY_WIDTH, "[deleted]",
-				REFCOL_WIDTH, "(none)", prettify_refname(ref->name));
+				TRANSPORT_SUMMARY_WIDTH, _("[deleted]"),
+				REFCOL_WIDTH, _("(none)"), prettify_refname(ref->name));
 			warn_dangling_symref(stderr, dangling_msg, ref->name);
 		}
 	}
-- 
1.7.2.2.614.g1dc9
Jonathan Nieder· Sep 2, 2010, 19:59 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 06/25] gettextize: git-fetch formatting messages

(+cc: some fetch ui authors, just as a heads up)
Ævar Arnfjörð Bjarmason wrote:
Show 9 quoted lines
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -236,7 +236,7 @@ static int update_local_ref(struct ref *ref,
>  	if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
>  		if (verbosity > 0)
>  			sprintf(display, "= %-*s %-*s -> %s", TRANSPORT_SUMMARY_WIDTH,
> -				"[up to date]", REFCOL_WIDTH, remote,
> +				_("[up to date]"), REFCOL_WIDTH, remote,
>  				pretty_ref);

Longer-term question: do people like to translate this kind of thing (with the arrows and so on) differently for right-to-left languages or is that considered overkill?

Show 8 quoted lines
> @@ -249,8 +249,8 @@ static int update_local_ref(struct ref *ref,
>  		 * If this is the head, and it's not okay to update
>  		 * the head, and the old value of the head isn't empty...
>  		 */
> -		sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
> -			TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
> +		sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
> +			TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,

Regardless of the answer, we should probably be either consistently translating or not translating it within this patch. e.g. for not translating (though I suspect translating is the better choice):

		sprintf(display, "! %-*s %-*s -> %s  %s",
			TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
			pretty_ref, _("(can't fetch in current branch)"));
Show 8 quoted lines
> @@ -260,8 +260,8 @@ static int update_local_ref(struct ref *ref,
>  		int r;
>  		r = s_update_ref("updating tag", ref, 0);
>  		sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
> -			TRANSPORT_SUMMARY_WIDTH, "[tag update]", REFCOL_WIDTH, remote,
> -			pretty_ref, r ? "  (unable to update local ref)" : "");
> +			TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), REFCOL_WIDTH, remote,
> +			pretty_ref, r ? _("  (unable to update local ref)") : "");

Maybe we could stick to "%c %-*s %-*s -> %s%s", to make consistent translation easier.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 20:13 UTC · re: Jonathan Nieder · lore

Re: [PATCH 06/25] gettextize: git-fetch formatting messages

On Thu, Sep 2, 2010 at 19:59, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 17 quoted lines
> (+cc: some fetch ui authors, just as a heads up)
>
> Ævar Arnfjörð Bjarmason wrote:
>
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -236,7 +236,7 @@ static int update_local_ref(struct ref *ref,
>>       if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
>>               if (verbosity > 0)
>>                       sprintf(display, "= %-*s %-*s -> %s", TRANSPORT_SUMMARY_WIDTH,
>> -                             "[up to date]", REFCOL_WIDTH, remote,
>> +                             _("[up to date]"), REFCOL_WIDTH, remote,
>>                               pretty_ref);
>
> Longer-term question: do people like to translate this kind of thing
> (with the arrows and so on) differently for right-to-left languages or
> is that considered overkill?

They do, on a RTL language the arrows are pointing the wrong way round. But for now I'm not trying to solve RTL issues (or indeed, word order or plural issues), just getting something basic going.

Show 12 quoted lines
>> @@ -249,8 +249,8 @@ static int update_local_ref(struct ref *ref,
>>                * If this is the head, and it's not okay to update
>>                * the head, and the old value of the head isn't empty...
>>                */
>> -             sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
>> -                     TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
>> +             sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
>> +                     TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
>
> Regardless of the answer, we should probably be either consistently
> translating or not translating it within this patch.  e.g. for not
> translating (though I suspect translating is the better choice):

I added a _() there because there's English language text in the message. I wouldn't have marked it if it was just "! %-*s %-*s -> %s".

And I haven't split up "! %-*s %-*s -> %s" and " (can't fetch in current branch)" because I'm trying to make minimal changes so that this can get through in a timely manner, before I have a mountain of merge conflicts on my hands.

But yeah, we want to fix that in the future.
Show 15 quoted lines
>                sprintf(display, "! %-*s %-*s -> %s  %s",
>                        TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
>                        pretty_ref, _("(can't fetch in current branch)"));
>
>> @@ -260,8 +260,8 @@ static int update_local_ref(struct ref *ref,
>>               int r;
>>               r = s_update_ref("updating tag", ref, 0);
>>               sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
>> -                     TRANSPORT_SUMMARY_WIDTH, "[tag update]", REFCOL_WIDTH, remote,
>> -                     pretty_ref, r ? "  (unable to update local ref)" : "");
>> +                     TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), REFCOL_WIDTH, remote,
>> +                     pretty_ref, r ? _("  (unable to update local ref)") : "");
>
> Maybe we could stick to "%c %-*s %-*s -> %s%s", to make consistent
> translation easier.

Yeah, maybe. That's pretty much the only part of this series that deals with issues like that. So it's probably worth a fixup.

(I.e. ignore what I said earlier :)
Jeff King· Sep 2, 2010, 20:28 UTC · re: Jonathan Nieder · lore

Re: [PATCH 06/25] gettextize: git-fetch formatting messages

On Thu, Sep 02, 2010 at 02:59:37PM -0500, Jonathan Nieder wrote:
> (+cc: some fetch ui authors, just as a heads up)

Thanks. I think Nico actually did the fetch code, though, and I more or less copied it for push.

Show 16 quoted lines
> > @@ -249,8 +249,8 @@ static int update_local_ref(struct ref *ref,
> >  		 * If this is the head, and it's not okay to update
> >  		 * the head, and the old value of the head isn't empty...
> >  		 */
> > -		sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
> > -			TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
> > +		sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
> > +			TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
> 
> Regardless of the answer, we should probably be either consistently
> translating or not translating it within this patch.  e.g. for not
> translating (though I suspect translating is the better choice):
> 
> 		sprintf(display, "! %-*s %-*s -> %s  %s",
> 			TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
> 			pretty_ref, _("(can't fetch in current branch)"));
I think you can translate "[rejected]" here, too.

However, do be aware of the --porcelain output for git-push. It was tacked on much later, and I fear it may use some of the same strings. Some of them are perhaps OK to translate (the human readable bit at the end, e.g.), but others maybe not. I haven't looked closely.

-Peff
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 20:48 UTC · re: Jeff King · lore

Re: [PATCH 06/25] gettextize: git-fetch formatting messages

On Thu, Sep 2, 2010 at 20:28, Jeff King <peff@peff.net> wrote:
Show 25 quoted lines
> On Thu, Sep 02, 2010 at 02:59:37PM -0500, Jonathan Nieder wrote:
>
>> (+cc: some fetch ui authors, just as a heads up)
>
> Thanks. I think Nico actually did the fetch code, though, and I more or
> less copied it for push.
>
>> > @@ -249,8 +249,8 @@ static int update_local_ref(struct ref *ref,
>> >              * If this is the head, and it's not okay to update
>> >              * the head, and the old value of the head isn't empty...
>> >              */
>> > -           sprintf(display, "! %-*s %-*s -> %s  (can't fetch in current branch)",
>> > -                   TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
>> > +           sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
>> > +                   TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
>>
>> Regardless of the answer, we should probably be either consistently
>> translating or not translating it within this patch.  e.g. for not
>> translating (though I suspect translating is the better choice):
>>
>>               sprintf(display, "! %-*s %-*s -> %s  %s",
>>                       TRANSPORT_SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
>>                       pretty_ref, _("(can't fetch in current branch)"));
>
> I think you can translate "[rejected]" here, too.
Thanks. I missed that one.
> However, do be aware of the --porcelain output for git-push. It was
> tacked on much later, and I fear it may use some of the same strings.
> Some of them are perhaps OK to translate (the human readable bit at the
> end, e.g.), but others maybe not. I haven't looked closely.

There's probably more potential issues like that because I didn't know the code well, but hopefully not too many.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 07/25] gettextize: git-grep basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/grep.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)
Show changes to builtin/grep.c +17 −17
diff --git a/builtin/grep.c b/builtin/grep.c
index da32f3d..af5d227 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -249,7 +249,7 @@ static void start_threads(struct grep_opt *opt)
 		err = pthread_create(&threads[i], NULL, run, o);
 
 		if (err)
-			die("grep: failed to create thread: %s",
+			die(_("grep: failed to create thread: %s"),
 			    strerror(err));
 	}
 }
@@ -454,7 +454,7 @@ static void *load_sha1(const unsigned char *sha1, unsigned long *size,
 	void *data = lock_and_read_sha1_file(sha1, &type, size);
 
 	if (!data)
-		error("'%s': unable to read %s", name, sha1_to_hex(sha1));
+		error(_("'%s': unable to read %s"), name, sha1_to_hex(sha1));
 
 	return data;
 }
@@ -505,7 +505,7 @@ static void *load_file(const char *filename, size_t *sz)
 	if (lstat(filename, &st) < 0) {
 	err_ret:
 		if (errno != ENOENT)
-			error("'%s': %s", filename, strerror(errno));
+			error(_("'%s': %s"), filename, strerror(errno));
 		return 0;
 	}
 	if (!S_ISREG(st.st_mode))
@@ -516,7 +516,7 @@ static void *load_file(const char *filename, size_t *sz)
 		goto err_ret;
 	data = xmalloc(*sz + 1);
 	if (st.st_size != read_in_full(i, data, *sz)) {
-		error("'%s': short read %s", filename, strerror(errno));
+		error(_("'%s': short read %s"), filename, strerror(errno));
 		close(i);
 		free(data);
 		return 0;
@@ -578,7 +578,7 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
 	argv[path_list->nr] = NULL;
 
 	if (prefix && chdir(prefix))
-		die("Failed to chdir: %s", prefix);
+		die(_("Failed to chdir: %s"), prefix);
 	status = run_command_v_opt(argv, RUN_USING_SHELL);
 	if (status)
 		exit(status);
@@ -668,7 +668,7 @@ static int grep_tree(struct grep_opt *opt, const char **paths,
 
 			data = lock_and_read_sha1_file(entry.sha1, &type, &size);
 			if (!data)
-				die("unable to read tree (%s)",
+				die(_("unable to read tree (%s)"),
 				    sha1_to_hex(entry.sha1));
 			init_tree_desc(&sub, data, size);
 			hit |= grep_tree(opt, paths, &sub, tree_name, down);
@@ -694,13 +694,13 @@ static int grep_object(struct grep_opt *opt, const char **paths,
 		data = read_object_with_reference(obj->sha1, tree_type,
 						  &size, NULL);
 		if (!data)
-			die("unable to read tree (%s)", sha1_to_hex(obj->sha1));
+			die(_("unable to read tree (%s)"), sha1_to_hex(obj->sha1));
 		init_tree_desc(&tree, data, size);
 		hit = grep_tree(opt, paths, &tree, name, "");
 		free(data);
 		return hit;
 	}
-	die("unable to grep from object of type %s", typename(obj->type));
+	die(_("unable to grep from object of type %s"), typename(obj->type));
 }
 
 static int grep_objects(struct grep_opt *opt, const char **paths,
@@ -752,7 +752,7 @@ static int context_callback(const struct option *opt, const char *arg,
 	}
 	value = strtol(arg, (char **)&endp, 10);
 	if (*endp) {
-		return error("switch `%c' expects a numerical value",
+		return error(_("switch `%c' expects a numerical value"),
 			     opt->short_name);
 	}
 	grep_opt->pre_context = grep_opt->post_context = value;
@@ -768,7 +768,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
 
 	patterns = fopen(arg, "r");
 	if (!patterns)
-		die_errno("cannot open '%s'", arg);
+		die_errno(_("cannot open '%s'"), arg);
 	while (strbuf_getline(&sb, patterns, '\n') == 0) {
 		char *s;
 		size_t len;
@@ -1009,11 +1009,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	}
 
 	if (!opt.pattern_list)
-		die("no pattern given.");
+		die(_("no pattern given."));
 	if (!opt.fixed && opt.ignore_case)
 		opt.regflags |= REG_ICASE;
 	if ((opt.regflags != REG_NEWLINE) && opt.fixed)
-		die("cannot mix --fixed-strings and regexp");
+		die(_("cannot mix --fixed-strings and regexp"));
 
 #ifndef NO_PTHREADS
 	if (online_cpus() == 1 || !grep_threads_ok(&opt))
@@ -1038,7 +1038,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 		if (!get_sha1(arg, sha1)) {
 			struct object *object = parse_object(sha1);
 			if (!object)
-				die("bad object %s", arg);
+				die(_("bad object %s"), arg);
 			add_object_array(object, arg, &list);
 			continue;
 		}
@@ -1065,7 +1065,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	}
 
 	if (show_in_pager && (cached || list.nr))
-		die("--open-files-in-pager only works on the worktree");
+		die(_("--open-files-in-pager only works on the worktree"));
 
 	if (show_in_pager && opt.pattern_list && !opt.pattern_list->next) {
 		const char *pager = path_list.items[0].string;
@@ -1090,9 +1090,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 
 	if (!use_index) {
 		if (cached)
-			die("--cached cannot be used with --no-index.");
+			die(_("--cached cannot be used with --no-index."));
 		if (list.nr)
-			die("--no-index cannot be used with revs.");
+			die(_("--no-index cannot be used with revs."));
 		hit = grep_directory(&opt, paths);
 	} else if (!list.nr) {
 		if (!cached)
@@ -1101,7 +1101,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 		hit = grep_cache(&opt, paths, cached);
 	} else {
 		if (cached)
-			die("both --cached and trees are given.");
+			die(_("both --cached and trees are given."));
 		hit = grep_objects(&opt, paths, &list);
 	}
 
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 08/25] gettextize: git-log basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/log.c |   74 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 37 insertions(+), 37 deletions(-)
Show changes to builtin/log.c +37 −37
diff --git a/builtin/log.c b/builtin/log.c
index ed8598e..460353b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -141,9 +141,9 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 			free((void *)fullpath);
 			if (range->nr == 0) {
 				if (range->next) {
-					die("Path %s need a -L <range> option\n"
+					die(_("Path %s need a -L <range> option\n"
 					"If you want follow the history of the whole file "
-					"use 'git log -L 1,$ <path>'", range->spec->path);
+					"use 'git log -L 1,$ <path>'"), range->spec->path);
 				} else {
 					parse_options_next(&ctx, 1);
 					continue;
@@ -167,7 +167,7 @@ parse_done:
 
 	/* die if '-L <range>' with no pathspec follow */
 	if (range->nr > 0 && range->spec == NULL)
-		die("Each -L should follow a path");
+		die(_("Each -L should follow a path"));
 	/* clear up the last range */
 	if (range->nr == 0) {
 		struct diff_line_range *r = range->next;
@@ -201,7 +201,7 @@ parse_done:
 			const char *v = skip_prefix(arg, "--decorate=");
 			decoration_style = parse_decoration_style(arg, v);
 			if (decoration_style < 0)
-				die("invalid --decorate option: %s", arg);
+				die(_("invalid --decorate option: %s"), arg);
 			decoration_given = 1;
 		} else if (!strcmp(arg, "--no-decorate")) {
 			decoration_style = 0;
@@ -210,7 +210,7 @@ parse_done:
 		} else if (!strcmp(arg, "-h")) {
 			usage(builtin_log_usage);
 		} else
-			die("unrecognized argument: %s", arg);
+			die(_("unrecognized argument: %s"), arg);
 	}
 
 	/*
@@ -259,7 +259,7 @@ static void show_early_header(struct rev_info *rev, const char *stage, int nr)
 		if (rev->commit_format != CMIT_FMT_ONELINE)
 			putchar(rev->diffopt.line_termination);
 	}
-	printf("Final output: %d %s\n", nr, stage);
+	printf(_("Final output: %d %s\n"), nr, stage);
 }
 
 static struct itimerval early_output_timer;
@@ -358,7 +358,7 @@ static int cmd_log_walk(struct rev_info *rev)
 		setup_early_output(rev);
 
 	if (prepare_revision_walk(rev))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	if (rev->early_output)
 		finish_early_output(rev);
@@ -450,7 +450,7 @@ static int show_object(const unsigned char *sha1, int show_tag_object,
 	int offset = 0;
 
 	if (!buf)
-		return error("Could not read object %s", sha1_to_hex(sha1));
+		return error(_("Could not read object %s"), sha1_to_hex(sha1));
 
 	if (show_tag_object)
 		while (offset < size && buf[offset] != '\n') {
@@ -537,7 +537,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 				break;
 			o = parse_object(t->tagged->sha1);
 			if (!o)
-				ret = error("Could not read object %s",
+				ret = error(_("Could not read object %s"),
 					    sha1_to_hex(t->tagged->sha1));
 			objects[i].item = o;
 			i--;
@@ -561,7 +561,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 			ret = cmd_log_walk(&rev);
 			break;
 		default:
-			ret = error("Unknown type: %d", o->type);
+			ret = error(_("Unknown type: %d"), o->type);
 		}
 	}
 	free(objects);
@@ -664,7 +664,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 {
 	if (!strcmp(var, "format.headers")) {
 		if (!value)
-			die("format.headers without value");
+			die(_("format.headers without value"));
 		add_header(value);
 		return 0;
 	}
@@ -736,7 +736,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)
 		strbuf_addstr(&filename, output_directory);
 		if (filename.len >=
 		    PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len)
-			return error("name of output directory is too long");
+			return error(_("name of output directory is too long"));
 		if (filename.buf[filename.len - 1] != '/')
 			strbuf_addch(&filename, '/');
 	}
@@ -747,7 +747,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev)
 		fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
 
 	if (freopen(filename.buf, "w", stdout) == NULL)
-		return error("Cannot open patch file %s", filename.buf);
+		return error(_("Cannot open patch file %s"), filename.buf);
 
 	strbuf_release(&filename);
 	return 0;
@@ -761,7 +761,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
 	unsigned flags1, flags2;
 
 	if (rev->pending.nr != 2)
-		die("Need exactly one range.");
+		die(_("Need exactly one range."));
 
 	o1 = rev->pending.objects[0].item;
 	flags1 = o1->flags;
@@ -769,7 +769,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
 	flags2 = o2->flags;
 
 	if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
-		die("Not a range.");
+		die(_("Not a range."));
 
 	init_patch_ids(ids);
 
@@ -780,7 +780,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
 	add_pending_object(&check_rev, o1, "o1");
 	add_pending_object(&check_rev, o2, "o2");
 	if (prepare_revision_walk(&check_rev))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	while ((commit = get_revision(&check_rev)) != NULL) {
 		/* ignore merges */
@@ -806,7 +806,7 @@ static void gen_message_id(struct rev_info *info, char *base)
 	const char *email_end = strrchr(committer, '>');
 	struct strbuf buf = STRBUF_INIT;
 	if (!email_start || !email_end || email_start > email_end - 1)
-		die("Could not extract email from committer identity.");
+		die(_("Could not extract email from committer identity."));
 	strbuf_addf(&buf, "%s.%lu.git.%.*s", base,
 		    (unsigned long) time(NULL),
 		    (int)(email_end - email_start - 1), email_start + 1);
@@ -838,7 +838,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 	struct commit *commit = NULL;
 
 	if (rev->commit_format != CMIT_FMT_EMAIL)
-		die("Cover letter needs email format");
+		die(_("Cover letter needs email format"));
 
 	committer = git_committer_info(0);
 
@@ -931,7 +931,7 @@ static const char *clean_message_id(const char *msg_id)
 		m++;
 	}
 	if (!z)
-		die("insane in-reply-to: %s", msg_id);
+		die(_("insane in-reply-to: %s"), msg_id);
 	if (++z == m)
 		return a;
 	return xmemdupz(a, z - a);
@@ -1004,7 +1004,7 @@ static int output_directory_callback(const struct option *opt, const char *arg,
 {
 	const char **dir = (const char **)opt->value;
 	if (*dir)
-		die("Two output directories?");
+		die(_("Two output directories?"));
 	*dir = arg;
 	return 0;
 }
@@ -1192,7 +1192,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
 		endpos = strchr(committer, '>');
 		if (!endpos)
-			die("bogus committer info %s", committer);
+			die(_("bogus committer info %s"), committer);
 		add_signoff = xmemdupz(committer, endpos - committer + 1);
 	}
 
@@ -1237,20 +1237,20 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		numbered = 0;
 
 	if (numbered && keep_subject)
-		die ("-n and -k are mutually exclusive.");
+		die (_("-n and -k are mutually exclusive."));
 	if (keep_subject && subject_prefix)
-		die ("--subject-prefix and -k are mutually exclusive.");
+		die (_("--subject-prefix and -k are mutually exclusive."));
 
 	argc = setup_revisions(argc, argv, &rev, &s_r_opt);
 	if (argc > 1)
-		die ("unrecognized argument: %s", argv[1]);
+		die (_("unrecognized argument: %s"), argv[1]);
 
 	if (rev.diffopt.output_format & DIFF_FORMAT_NAME)
-		die("--name-only does not make sense");
+		die(_("--name-only does not make sense"));
 	if (rev.diffopt.output_format & DIFF_FORMAT_NAME_STATUS)
-		die("--name-status does not make sense");
+		die(_("--name-status does not make sense"));
 	if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)
-		die("--check does not make sense");
+		die(_("--check does not make sense"));
 
 	if (!use_patch_format &&
 		(!rev.diffopt.output_format ||
@@ -1271,9 +1271,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 
 	if (output_directory) {
 		if (use_stdout)
-			die("standard output, or directory, which one?");
+			die(_("standard output, or directory, which one?"));
 		if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
-			die_errno("Could not create directory '%s'",
+			die_errno(_("Could not create directory '%s'"),
 				  output_directory);
 	}
 
@@ -1327,7 +1327,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		realstdout = xfdopen(xdup(1), "w");
 
 	if (prepare_revision_walk(&rev))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 	rev.boundary = 1;
 	while ((commit = get_revision(&rev)) != NULL) {
 		if (commit->object.flags & BOUNDARY) {
@@ -1408,7 +1408,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 
 		if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
 						 &rev))
-			die("Failed to create output files");
+			die(_("Failed to create output files"));
 		shown = log_tree_commit(&rev, commit);
 		free(commit->buffer);
 		commit->buffer = NULL;
@@ -1495,9 +1495,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
 		if (!current_branch || !current_branch->merge
 					|| !current_branch->merge[0]
 					|| !current_branch->merge[0]->dst) {
-			fprintf(stderr, "Could not find a tracked"
+			fprintf(stderr, _("Could not find a tracked"
 					" remote branch, please"
-					" specify <upstream> manually.\n");
+					" specify <upstream> manually.\n"));
 			usage_with_options(cherry_usage, options);
 		}
 
@@ -1511,9 +1511,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
 	DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
 
 	if (add_pending_commit(head, &revs, 0))
-		die("Unknown commit %s", head);
+		die(_("Unknown commit %s"), head);
 	if (add_pending_commit(upstream, &revs, UNINTERESTING))
-		die("Unknown commit %s", upstream);
+		die(_("Unknown commit %s"), upstream);
 
 	/* Don't say anything if head and upstream are the same. */
 	if (revs.pending.nr == 2) {
@@ -1525,11 +1525,11 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
 	get_patch_ids(&revs, &ids, prefix);
 
 	if (limit && add_pending_commit(limit, &revs, UNINTERESTING))
-		die("Unknown commit %s", limit);
+		die(_("Unknown commit %s"), limit);
 
 	/* reverse the list of commits */
 	if (prepare_revision_walk(&revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 	while ((commit = get_revision(&revs)) != NULL) {
 		/* ignore merges */
 		if (commit->parents && commit->parents->next)
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 09/25] gettextize: git-format-patch --cover-letter message

Make the "SUBJECT HERE" and "BLURB HERE" output in git-format-patch translatable. This is going to be edited by a human anyway.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/log.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to builtin/log.c +1 −1
diff --git a/builtin/log.c b/builtin/log.c
index 460353b..6a4a8f7 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -826,7 +826,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 {
 	const char *committer;
 	const char *subject_start = NULL;
-	const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
+	const char *body = _("*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n");
 	const char *msg;
 	const char *extra_headers = rev->extra_headers;
 	struct shortlog log;
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 10/25] gettextize: git-merge basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/merge.c |  124 +++++++++++++++++++++++++++---------------------------
 1 files changed, 62 insertions(+), 62 deletions(-)
Show changes to builtin/merge.c +62 −62
diff --git a/builtin/merge.c b/builtin/merge.c
index a7e3313..bf3b313 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -79,7 +79,7 @@ static int option_parse_message(const struct option *opt,
 		strbuf_addf(buf, "%s%s", buf->len ? "\n\n" : "", arg);
 		have_message = 1;
 	} else
-		return error("switch `m' requires a value");
+		return error(_("switch `m' requires a value"));
 	return 0;
 }
 
@@ -116,13 +116,13 @@ static struct strategy *get_strategy(const char *name)
 		exclude_cmds(&main_cmds, &not_strategies);
 	}
 	if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
-		fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
-		fprintf(stderr, "Available strategies are:");
+		fprintf(stderr, _("Could not find merge strategy '%s'.\n"), name);
+		fprintf(stderr, _("Available strategies are:"));
 		for (i = 0; i < main_cmds.cnt; i++)
 			fprintf(stderr, " %s", main_cmds.names[i]->name);
 		fprintf(stderr, ".\n");
 		if (other_cmds.cnt) {
-			fprintf(stderr, "Available custom strategies are:");
+			fprintf(stderr, _("Available custom strategies are:"));
 			for (i = 0; i < other_cmds.cnt; i++)
 				fprintf(stderr, " %s", other_cmds.names[i]->name);
 			fprintf(stderr, ".\n");
@@ -223,17 +223,17 @@ static void save_state(void)
 	cp.git_cmd = 1;
 
 	if (start_command(&cp))
-		die("could not run stash.");
+		die(_("could not run stash."));
 	len = strbuf_read(&buffer, cp.out, 1024);
 	close(cp.out);
 
 	if (finish_command(&cp) || len < 0)
-		die("stash failed");
+		die(_("stash failed"));
 	else if (!len)
 		return;
 	strbuf_setlen(&buffer, buffer.len-1);
 	if (get_sha1(buffer.buf, stash))
-		die("not a valid object: %s", buffer.buf);
+		die(_("not a valid object: %s"), buffer.buf);
 }
 
 static void reset_hard(unsigned const char *sha1, int verbose)
@@ -250,7 +250,7 @@ static void reset_hard(unsigned const char *sha1, int verbose)
 	args[i] = NULL;
 
 	if (run_command_v_opt(args, RUN_GIT_CMD))
-		die("read-tree failed");
+		die(_("read-tree failed"));
 }
 
 static void restore_state(void)
@@ -279,7 +279,7 @@ static void restore_state(void)
 static void finish_up_to_date(const char *msg)
 {
 	if (verbosity >= 0)
-		printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+		printf("%s%s\n", squash ? _(" (nothing to squash)") : "", msg);
 	drop_save();
 }
 
@@ -292,10 +292,10 @@ static void squash_message(void)
 	int fd;
 	struct pretty_print_context ctx = {0};
 
-	printf("Squash commit -- not updating HEAD\n");
+	printf(_("Squash commit -- not updating HEAD\n"));
 	fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
 	if (fd < 0)
-		die_errno("Could not write to '%s'", git_path("SQUASH_MSG"));
+		die_errno(_("Could not write to '%s'"), git_path("SQUASH_MSG"));
 
 	init_revisions(&rev, NULL);
 	rev.ignore_merges = 1;
@@ -310,7 +310,7 @@ static void squash_message(void)
 
 	setup_revisions(0, NULL, &rev, NULL);
 	if (prepare_revision_walk(&rev))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	ctx.abbrev = rev.abbrev;
 	ctx.date_mode = rev.date_mode;
@@ -323,9 +323,9 @@ static void squash_message(void)
 		pretty_print_commit(rev.commit_format, commit, &out, &ctx);
 	}
 	if (write(fd, out.buf, out.len) < 0)
-		die_errno("Writing SQUASH_MSG");
+		die_errno(_("Writing SQUASH_MSG"));
 	if (close(fd))
-		die_errno("Finishing SQUASH_MSG");
+		die_errno(_("Finishing SQUASH_MSG"));
 	strbuf_release(&out);
 }
 
@@ -345,7 +345,7 @@ static void finish(const unsigned char *new_head, const char *msg)
 		squash_message();
 	} else {
 		if (verbosity >= 0 && !merge_msg.len)
-			printf("No merge message -- not updating HEAD\n");
+			printf(_("No merge message -- not updating HEAD\n"));
 		else {
 			const char *argv_gc_auto[] = { "gc", "--auto", NULL };
 			update_ref(reflog_message.buf, "HEAD",
@@ -367,7 +367,7 @@ static void finish(const unsigned char *new_head, const char *msg)
 		if (diff_use_color_default > 0)
 			DIFF_OPT_SET(&opts, COLOR_DIFF);
 		if (diff_setup_done(&opts) < 0)
-			die("diff_setup_done failed");
+			die(_("diff_setup_done failed"));
 		diff_tree_sha1(head, new_head, "", &opts);
 		diffcore_std(&opts);
 		diff_flush(&opts);
@@ -396,7 +396,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
 	memset(branch_head, 0, sizeof(branch_head));
 	remote_head = peel_to_type(remote, 0, NULL, OBJ_COMMIT);
 	if (!remote_head)
-		die("'%s' does not point to a commit", remote);
+		die(_("'%s' does not point to a commit"), remote);
 
 	if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
 		if (!prefixcmp(found_ref, "refs/heads/")) {
@@ -461,7 +461,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
 
 		fp = fopen(git_path("FETCH_HEAD"), "r");
 		if (!fp)
-			die_errno("could not open '%s' for reading",
+			die_errno(_("could not open '%s' for reading"),
 				  git_path("FETCH_HEAD"));
 		strbuf_getline(&line, fp, '\n');
 		fclose(fp);
@@ -491,7 +491,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 		buf = xstrdup(v);
 		argc = split_cmdline(buf, &argv);
 		if (argc < 0)
-			die("Bad branch.%s.mergeoptions string: %s", branch,
+			die(_("Bad branch.%s.mergeoptions string: %s"), branch,
 			    split_cmdline_strerror(argc));
 		argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
 		memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
@@ -513,7 +513,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 		int is_bool;
 		shortlog_len = git_config_bool_or_int(k, v, &is_bool);
 		if (!is_bool && shortlog_len < 0)
-			return error("%s: negative length %s???", k, v);
+			return error(_("%s: negative length %s???"), k, v);
 		if ((is_bool && shortlog_len) || shortlog_len < 0)
 			shortlog_len = DEFAULT_MERGE_LOG_LEN;
 		return 0;
@@ -560,7 +560,7 @@ static int read_tree_trivial(unsigned char *common, unsigned char *head,
 static void write_tree_trivial(unsigned char *sha1)
 {
 	if (write_cache_as_tree(sha1, 0, NULL))
-		die("git write-tree failed to write a tree");
+		die(_("git write-tree failed to write a tree"));
 }
 
 int try_merge_command(const char *strategy, struct commit_list *common,
@@ -601,7 +601,7 @@ int try_merge_command(const char *strategy, struct commit_list *common,
 	free(args);
 	discard_cache();
 	if (read_cache() < 0)
-		die("failed to read the cache");
+		die(_("failed to read the cache"));
 	resolve_undo_clear();
 
 	return ret;
@@ -618,7 +618,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 	if (active_cache_changed &&
 			(write_cache(index_fd, active_cache, active_nr) ||
 			 commit_locked_index(lock)))
-		return error("Unable to write index.");
+		return error(_("Unable to write index."));
 	rollback_lock_file(lock);
 
 	if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
@@ -631,7 +631,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 		struct commit_list *j;
 
 		if (remoteheads->next) {
-			error("Not handling anything other than two heads merge.");
+			error(_("Not handling anything other than two heads merge."));
 			return 2;
 		}
 
@@ -643,7 +643,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 
 		for (x = 0; x < xopts_nr; x++)
 			if (parse_merge_opt(&o, xopts[x]))
-				die("Unknown option for merge-recursive: -X%s", xopts[x]);
+				die(_("Unknown option for merge-recursive: -X%s"), xopts[x]);
 
 		o.branch1 = head_arg;
 		o.branch2 = remoteheads->item->util;
@@ -657,7 +657,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 		if (active_cache_changed &&
 				(write_cache(index_fd, active_cache, active_nr) ||
 				 commit_locked_index(lock)))
-			die ("unable to write %s", get_index_file());
+			die (_("unable to write %s"), get_index_file());
 		rollback_lock_file(lock);
 		return clean ? 0 : 1;
 	} else {
@@ -731,7 +731,7 @@ int checkout_fast_forward(const unsigned char *head, const unsigned char *remote
 		return -1;
 	if (write_cache(fd, active_cache, active_nr) ||
 		commit_locked_index(lock_file))
-		die("unable to write new index file");
+		die(_("unable to write new index file"));
 	return 0;
 }
 
@@ -785,7 +785,7 @@ static int merge_trivial(void)
 	struct commit_list *parent = xmalloc(sizeof(*parent));
 
 	write_tree_trivial(result_tree);
-	printf("Wonderful.\n");
+	printf(_("Wonderful.\n"));
 	parent->item = lookup_commit(head);
 	parent->next = xmalloc(sizeof(*parent->next));
 	parent->next->item = remoteheads->item;
@@ -834,7 +834,7 @@ static int suggest_conflicts(int renormalizing)
 
 	fp = fopen(git_path("MERGE_MSG"), "a");
 	if (!fp)
-		die_errno("Could not open '%s' for writing",
+		die_errno(_("Could not open '%s' for writing"),
 			  git_path("MERGE_MSG"));
 	fprintf(fp, "\nConflicts:\n");
 	for (pos = 0; pos < active_nr; pos++) {
@@ -850,8 +850,8 @@ static int suggest_conflicts(int renormalizing)
 	}
 	fclose(fp);
 	rerere(allow_rerere_auto);
-	printf("Automatic merge failed; "
-			"fix conflicts and then commit the result.\n");
+	printf(_("Automatic merge failed; "
+			"fix conflicts and then commit the result.\n"));
 	return 1;
 }
 
@@ -865,7 +865,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv)
 			return NULL;
 		second_token = lookup_commit_reference_gently(second_sha1, 0);
 		if (!second_token)
-			die("'%s' is not a commit", argv[1]);
+			die(_("'%s' is not a commit"), argv[1]);
 		if (hashcmp(second_token->object.sha1, head))
 			return NULL;
 	}
@@ -915,10 +915,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		 * add/rm <file>', just 'git commit'.
 		 */
 		if (advice_resolve_conflict)
-			die("You have not concluded your merge (MERGE_HEAD exists).\n"
-			    "Please, commit your changes before you can merge.");
+			die(_("You have not concluded your merge (MERGE_HEAD exists).\n"
+			    "Please, commit your changes before you can merge."));
 		else
-			die("You have not concluded your merge (MERGE_HEAD exists).");
+			die(_("You have not concluded your merge (MERGE_HEAD exists)."));
 	}
 
 	resolve_undo_clear();
@@ -945,12 +945,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
 	if (squash) {
 		if (!allow_fast_forward)
-			die("You cannot combine --squash with --no-ff.");
+			die(_("You cannot combine --squash with --no-ff."));
 		option_commit = 0;
 	}
 
 	if (!allow_fast_forward && fast_forward_only)
-		die("You cannot combine --no-ff with --ff-only.");
+		die(_("You cannot combine --no-ff with --ff-only."));
 
 	if (!argc)
 		usage_with_options(builtin_merge_usage,
@@ -978,16 +978,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		 * We do the same for "git pull".
 		 */
 		if (argc != 1)
-			die("Can merge only exactly one commit into "
-				"empty head");
+			die(_("Can merge only exactly one commit into "
+				"empty head"));
 		if (squash)
-			die("Squash commit into empty head not supported yet");
+			die(_("Squash commit into empty head not supported yet"));
 		if (!allow_fast_forward)
-			die("Non-fast-forward commit does not make sense into "
-			    "an empty head");
+			die(_("Non-fast-forward commit does not make sense into "
+			    "an empty head"));
 		remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
 		if (!remote_head)
-			die("%s - not something we can merge", argv[0]);
+			die(_("%s - not something we can merge"), argv[0]);
 		update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
 				DIE_ON_ERR);
 		reset_hard(remote_head->sha1, 0);
@@ -1033,7 +1033,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
 		o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
 		if (!o)
-			die("%s - not something we can merge", argv[i]);
+			die(_("%s - not something we can merge"), argv[i]);
 		commit = lookup_commit(o->sha1);
 		commit->util = (void *)argv[i];
 		remotes = &commit_list_insert(commit, remotes)->next;
@@ -1091,7 +1091,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
 
 		if (verbosity >= 0)
-			printf("Updating %s..%s\n",
+			printf(_("Updating %s..%s\n"),
 				hex,
 				find_unique_abbrev(remoteheads->item->object.sha1,
 				DEFAULT_ABBREV));
@@ -1125,11 +1125,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		if (allow_trivial && !fast_forward_only) {
 			/* See if it is really trivial. */
 			git_committer_info(IDENT_ERROR_ON_NO_NAME);
-			printf("Trying really trivial in-index merge...\n");
+			printf(_("Trying really trivial in-index merge...\n"));
 			if (!read_tree_trivial(common->item->object.sha1,
 					head, remoteheads->item->object.sha1))
 				return merge_trivial();
-			printf("Nope.\n");
+			printf(_("Nope.\n"));
 		}
 	} else {
 		/*
@@ -1162,7 +1162,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	}
 
 	if (fast_forward_only)
-		die("Not possible to fast-forward, aborting.");
+		die(_("Not possible to fast-forward, aborting."));
 
 	/* We are going to make a new commit. */
 	git_committer_info(IDENT_ERROR_ON_NO_NAME);
@@ -1188,11 +1188,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	for (i = 0; i < use_strategies_nr; i++) {
 		int ret;
 		if (i) {
-			printf("Rewinding the tree to pristine...\n");
+			printf(_("Rewinding the tree to pristine...\n"));
 			restore_state();
 		}
 		if (use_strategies_nr != 1)
-			printf("Trying merge strategy %s...\n",
+			printf(_("Trying merge strategy %s...\n"),
 				use_strategies[i]->name);
 		/*
 		 * Remember which strategy left the state in the working
@@ -1253,17 +1253,17 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		restore_state();
 		if (use_strategies_nr > 1)
 			fprintf(stderr,
-				"No merge strategy handled the merge.\n");
+				_("No merge strategy handled the merge.\n"));
 		else
-			fprintf(stderr, "Merge with strategy %s failed.\n",
+			fprintf(stderr, _("Merge with strategy %s failed.\n"),
 				use_strategies[0]->name);
 		return 2;
 	} else if (best_strategy == wt_strategy)
 		; /* We already have its result in the working tree. */
 	else {
-		printf("Rewinding the tree to pristine...\n");
+		printf(_("Rewinding the tree to pristine...\n"));
 		restore_state();
-		printf("Using the %s to prepare resolving by hand.\n",
+		printf(_("Using the %s to prepare resolving by hand.\n"),
 			best_strategy);
 		try_merge_strategy(best_strategy, common, head_arg);
 	}
@@ -1279,35 +1279,35 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 				sha1_to_hex(j->item->object.sha1));
 		fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
 		if (fd < 0)
-			die_errno("Could not open '%s' for writing",
+			die_errno(_("Could not open '%s' for writing"),
 				  git_path("MERGE_HEAD"));
 		if (write_in_full(fd, buf.buf, buf.len) != buf.len)
-			die_errno("Could not write to '%s'", git_path("MERGE_HEAD"));
+			die_errno(_("Could not write to '%s'"), git_path("MERGE_HEAD"));
 		close(fd);
 		strbuf_addch(&merge_msg, '\n');
 		fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
 		if (fd < 0)
-			die_errno("Could not open '%s' for writing",
+			die_errno(_("Could not open '%s' for writing"),
 				  git_path("MERGE_MSG"));
 		if (write_in_full(fd, merge_msg.buf, merge_msg.len) !=
 			merge_msg.len)
-			die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
+			die_errno(_("Could not write to '%s'"), git_path("MERGE_MSG"));
 		close(fd);
 		fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
 		if (fd < 0)
-			die_errno("Could not open '%s' for writing",
+			die_errno(_("Could not open '%s' for writing"),
 				  git_path("MERGE_MODE"));
 		strbuf_reset(&buf);
 		if (!allow_fast_forward)
 			strbuf_addf(&buf, "no-ff");
 		if (write_in_full(fd, buf.buf, buf.len) != buf.len)
-			die_errno("Could not write to '%s'", git_path("MERGE_MODE"));
+			die_errno(_("Could not write to '%s'"), git_path("MERGE_MODE"));
 		close(fd);
 	}
 
 	if (merge_was_ok) {
-		fprintf(stderr, "Automatic merge went well; "
-			"stopped before committing as requested\n");
+		fprintf(stderr, _("Automatic merge went well; "
+			"stopped before committing as requested\n"));
 		return 0;
 	} else
 		return suggest_conflicts(option_renormalize);
-- 
1.7.2.2.614.g1dc9
Jonathan Nieder· Sep 2, 2010, 20:09 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

Ævar Arnfjörð Bjarmason wrote:
Show 10 quoted lines
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -116,13 +116,13 @@ static struct strategy *get_strategy(const char *name)
>  		exclude_cmds(&main_cmds, &not_strategies);
>  	}
>  	if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
> -		fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
> -		fprintf(stderr, "Available strategies are:");
> +		fprintf(stderr, _("Could not find merge strategy '%s'.\n"), name);
> +		fprintf(stderr, _("Available strategies are:"));

Another basic question (sorry for my ignorance): do translators prefer whole paragraphs or line-by-line messages like this? (Of course that is not a topic for this patch; I am just curious.)

Show 6 quoted lines
> @@ -513,7 +513,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
>  		int is_bool;
>  		shortlog_len = git_config_bool_or_int(k, v, &is_bool);
>  		if (!is_bool && shortlog_len < 0)
> -			return error("%s: negative length %s???", k, v);
> +			return error(_("%s: negative length %s???"), k, v);

What branch are you translating? I am hoping the omgwtfbbq??! message gets a chance to be tweaked before release.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 20:30 UTC · re: Jonathan Nieder · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

On Thu, Sep 2, 2010 at 20:09, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 16 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>
>> --- a/builtin/merge.c
>> +++ b/builtin/merge.c
>> @@ -116,13 +116,13 @@ static struct strategy *get_strategy(const char *name)
>>               exclude_cmds(&main_cmds, &not_strategies);
>>       }
>>       if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) {
>> -             fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
>> -             fprintf(stderr, "Available strategies are:");
>> +             fprintf(stderr, _("Could not find merge strategy '%s'.\n"), name);
>> +             fprintf(stderr, _("Available strategies are:"));
>
> Another basic question (sorry for my ignorance): do translators prefer
> whole paragraphs or line-by-line messages like this?  (Of course that
> is not a topic for this patch; I am just curious.)
  _("We want whole paragraphs"
    " for stuff like this where"
    " the message actually is a"
    " single paragraph of text")

However, in this case the message is a stand-alone error message followed by what's effectively new sentence (a header above strategies) followed by a listing of strategies.

That sort of thing isn't a problem, because fortunately we only have left-to-right languages, not bottom-to-top. At least it hasn't been an issue in MediaWiki (whose i18n I've worked on) which is translated to over 200 languages now.

Show 9 quoted lines
>> @@ -513,7 +513,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
>>               int is_bool;
>>               shortlog_len = git_config_bool_or_int(k, v, &is_bool);
>>               if (!is_bool && shortlog_len < 0)
>> -                     return error("%s: negative length %s???", k, v);
>> +                     return error(_("%s: negative length %s???"), k, v);
>
> What branch are you translating?  I am hoping the omgwtfbbq??! message
> gets a chance to be tweaked before release.

It's on top of pu, I've actually lost an up-to-date tip where gettext was applied to a branch below that, and haven't worked my way back.

Maybe this'll be a problem for this series. Here's the builtin/*.c changes between next and pu:

     builtin/checkout.c        |   14 ++-
     builtin/fetch.c           |   21 ++++-
     builtin/fmt-merge-msg.c   |   60 ++++++-----
     builtin/init-db.c         |   56 +++++-----
     builtin/log.c             |    7 +-
     builtin/mailinfo.c        |   10 ++-
     builtin/merge-recursive.c |   15 +---
     builtin/merge.c           |   62 +++++------
     builtin/notes.c           |   14 ++-
     builtin/remote-ext.c      |  257
+++++++++++++++++++++++++++++++++++++++++++++
     builtin/remote-fd.c       |   83 +++++++++++++++
     builtin/skew.c            |   50 +++++++++
     builtin/tag.c             |    2 +-
     builtin/version.c         |    7 ++
     14 files changed, 537 insertions(+), 121 deletions(-)

Some of these affect this series. But I was hoping that this would make it into pu and after next gets released Any Day Now most of those other tips in pu would be folded into next along with gettext, or at least the merge conflicts wouldn't be too painful.

Jonathan Nieder· Sep 2, 2010, 20:37 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

Ævar Arnfjörð Bjarmason wrote:
> It's on top of pu,
[...]
> But I was hoping that this would
> make it into pu and after next gets released Any Day Now most of those
> other tips in pu would be folded into next along with gettext, or at
> least the merge conflicts wouldn't be too painful.
Hmm.  That really constrains people trying to merge this series.
As SubmittingPatches explains:
 - In the exceptional case that a new feature depends on several topics
   not in 'master', start working on 'next' or 'pu' privately and send
   out patches for discussion. Before the final merge, you may have to
   wait until some of the dependent topics graduate to 'master', and
   rebase your work.

so this is fine for discussion, but for merging, having to pull in _all_ topics from pu (or all topics from next for that matter) for the patches to apply really is a problem.

Both next and pu get rewound from time to time. They are not meant to be a stable basis for patches.

Also worth mentioning is that topics in "next" are not guaranteed to be included in the next release. The "next" branch has content matching the "jch" branch which I think has a better name: it is just the version of git that Junio uses for ordinary tasks (and hence topics in it cannot be completely broken for long).

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 20:54 UTC · re: Jonathan Nieder · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

On Thu, Sep 2, 2010 at 20:37, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 31 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>
>> It's on top of pu,
> [...]
>> But I was hoping that this would
>> make it into pu and after next gets released Any Day Now most of those
>> other tips in pu would be folded into next along with gettext, or at
>> least the merge conflicts wouldn't be too painful.
>
> Hmm.  That really constrains people trying to merge this series.
>
> As SubmittingPatches explains:
>
>  - In the exceptional case that a new feature depends on several topics
>   not in 'master', start working on 'next' or 'pu' privately and send
>   out patches for discussion. Before the final merge, you may have to
>   wait until some of the dependent topics graduate to 'master', and
>   rebase your work.
>
> so this is fine for discussion, but for merging, having to pull in
> _all_ topics from pu (or all topics from next for that matter) for
> the patches to apply really is a problem.
>
> Both next and pu get rewound from time to time.  They are not meant
> to be a stable basis for patches.
>
> Also worth mentioning is that topics in "next" are not guaranteed to
> be included in the next release.  The "next" branch has content
> matching the "jch" branch which I think has a better name: it is
> just the version of git that Junio uses for ordinary tasks (and
> hence topics in it cannot be completely broken for long).
Yeah, I was just hoping I could get away with it :)

Having whatever Junio is using these days as ab/i18n would be convenient (since I've lost it), although I suppose I could start at master and cherry-pick my way forward.

I'll also wait for comment from Junio about what he wants done with it and what his plans are for it. But I can rebase it if need be.

Jonathan Nieder· Sep 2, 2010, 21:13 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

Ævar Arnfjörð Bjarmason wrote:
> Yeah, I was just hoping I could get away with it :)

To be clear, I think you made a reasonable choice at this stage of development.

Aside: maybe for translation (though not for gettextizing) the idea of
patches that get applied to the development tree is more trouble than
it's worth.  GNU sed and some similar projects do not include
translations in the development tree but fetch them from
translationproject.org as part of the "bootstrap" procedure when
building a source tarball or binaries.
See autoboot in git://git.sv.gnu.org/sed.git for example.
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 22:45 UTC · re: Jonathan Nieder · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

On Thu, Sep 2, 2010 at 21:13, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 8 quoted lines
> Aside: maybe for translation (though not for gettextizing) the idea of
> patches that get applied to the development tree is more trouble than
> it's worth.  GNU sed and some similar projects do not include
> translations in the development tree but fetch them from
> translationproject.org as part of the "bootstrap" procedure when
> building a source tarball or binaries.
>
> See autoboot in git://git.sv.gnu.org/sed.git for example.

I'd prefer to be able to submit translations directly to git.git, and build a localized git with "make" and no network access. Most programs that use gettext do this, sed seems to be an exception, and actually I've never seen anyone do it like that. Some maintain their translations in some web interface, but I haven't seen a project that doesn't commit them *at all*.

I can't see why translations in the tree (in po/) should be any trouble at all for us. What sort of issues do you see that the sed.git model might solve?

Jonathan Nieder· Sep 2, 2010, 23:04 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

Ævar Arnfjörð Bjarmason wrote:
> I can't see why translations in the tree (in po/) should be any
> trouble at all for us. What sort of issues do you see that the sed.git
> model might solve?
Only two: log noise and the problem of what to base patches on.

As you noticed while gettextizing (which is pretty much a one-time thing), it is not much fun to do work on strings that aren't even going to be used. So translators might want to work against "next", or at least "master". How do the translations get back to "maint"? Someone has to backport them. What happens when we merge back to "master"?

Now multiply that by the number of translations. Making messages merge up nicely with git tools as they drift from topic to topic if translators want to keep both "maint" and "master" translated would require at least a nice custom merge driver.

As we noticed before, the .po files are partially automatically generated anyway. Merging them as text makes about as much sense as merging Word-generated .rtf files as text. To avoid wasting time, one wants to be able to work with their _content_.

What is that content?

It is a set of key/value pairs: for each string that appears in the codebase (maybe together with disambiguating translators' notes), what the translation is for it. Merging that between branches of the code base is utterly trivial: take the union. Actually "merging" as an operation here does not make sense. It is not tied to the development history at all!

Imagine v6.0.0 of git has message "foo". v6.0.1 changes it to "bar" because "foo" is not actually true yet, v6.1.0 changes it back to "foo". Imagine a linear development history. Do we want translation diffs like this:

 commit v6.0.0
 +"foo" is "hello" in language X
 commit v6.0.1
 -"foo" is "hello" in language X
 +"bar" is "goodbye" in language X
 commit v6.1
 -"bar" is "goodbye" in language X
 +"foo" is "hello" in language X
?  But what really happened is this:
 - add foo:hello to translation database
 - add bar:goodbye to translation database

I have been thinking about how to write a merge driver for .po files (and avoid the tedious merge problems that e.g. the dpkg project runs into periodically) but the idea of avoiding that altogether is very appealing to me.

Ævar Arnfjörð Bjarmason· Sep 3, 2010, 12:13 UTC · re: Jonathan Nieder · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

On Thu, Sep 2, 2010 at 23:04, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 60 quoted lines
>> I can't see why translations in the tree (in po/) should be any
>> trouble at all for us. What sort of issues do you see that the sed.git
>> model might solve?
>
> Only two: log noise and the problem of what to base patches on.
>
> As you noticed while gettextizing (which is pretty much a one-time
> thing), it is not much fun to do work on strings that aren't even
> going to be used.  So translators might want to work against "next",
> or at least "master".  How do the translations get back to "maint"?
> Someone has to backport them.  What happens when we merge back to
> "master"?
>
> Now multiply that by the number of translations.  Making messages
> merge up nicely with git tools as they drift from topic to topic if
> translators want to keep both "maint" and "master" translated would
> require at least a nice custom merge driver.
>
> As we noticed before, the .po files are partially automatically
> generated anyway.  Merging them as text makes about as much sense
> as merging Word-generated .rtf files as text.  To avoid wasting time,
> one wants to be able to work with their _content_.
>
> What is that content?
>
> It is a set of key/value pairs: for each string that appears in
> the codebase (maybe together with disambiguating translators' notes),
> what the translation is for it.  Merging that between branches of the
> code base is utterly trivial: take the union.  Actually "merging" as
> an operation here does not make sense.  It is not tied to the
> development history at all!
>
> Imagine v6.0.0 of git has message "foo".  v6.0.1 changes it to "bar"
> because "foo" is not actually true yet, v6.1.0 changes it back to
> "foo".  Imagine a linear development history.  Do we want translation
> diffs like this:
>
>  commit v6.0.0
>
>  +"foo" is "hello" in language X
>
>  commit v6.0.1
>
>  -"foo" is "hello" in language X
>  +"bar" is "goodbye" in language X
>
>  commit v6.1
>
>  -"bar" is "goodbye" in language X
>  +"foo" is "hello" in language X
>
> ?  But what really happened is this:
>
>  - add foo:hello to translation database
>  - add bar:goodbye to translation database
>
> I have been thinking about how to write a merge driver for .po files
> (and avoid the tedious merge problems that e.g. the dpkg project runs
> into periodically) but the idea of avoiding that altogether is very
> appealing to me.

Those issues might be a bit hard, but I still can't really see how managing these files outside of git.git would make things easier.

You'd still need to do the merging of e.g. master -> maint translations, you'd just have to do them outside of git.git, so you wouldn't be able to do that using the normal merge facilities.

Maybe we can have a custom msgmerge merge driver (someone posted one in #git-devel, but I've misplaced it), or maybe we should just use msgmerge with --no-location.

But I'd like to coordinate things on this mailing list, and in git.git, without some external service being mandatory.

Jonathan Nieder· Sep 3, 2010, 17:51 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

Ævar Arnfjörð Bjarmason wrote:
> Those issues might be a bit hard, but I still can't really see how
> managing these files outside of git.git would make things easier.

The translationproject.org thing was a red herring. As you noticed, the relevant thing is "outside of git.git".

So imagine there is a git-translations.git project, perhaps. My only point was that versioning of translations and versioning of code can beneficially (in my opinion) be decoupled: with time, the translations for even _old_ versions of git improve, too.

> maybe we should just use
> msgmerge with --no-location.

That would partially alleviate my concerns, and I think we might be able to get the --add-location output back in actual checkouts with a "smudge" filter.

But still there is noise from reordering messages, adding them and removing them, and so on. It just never seemed like a great fit for the usual version control model to me.

> But I'd like to coordinate things on this mailing list
[...]
> without some external service being mandatory.
No objection here. :)

Of course, what is convenient for translators and maintainers (i.e., not me) takes precedence anyway; I am just throwing out ideas.

Thanks for your thoughtfulness.
Ævar Arnfjörð Bjarmason· Sep 3, 2010, 18:06 UTC · re: Jonathan Nieder · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

On Fri, Sep 3, 2010 at 17:51, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 19 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>
>> Those issues might be a bit hard, but I still can't really see how
>> managing these files outside of git.git would make things easier.
>
> The translationproject.org thing was a red herring.  As you noticed,
> the relevant thing is "outside of git.git".
>
> So imagine there is a git-translations.git project, perhaps.  My
> only point was that versioning of translations and versioning of
> code can beneficially (in my opinion) be decoupled: with time,
> the translations for even _old_ versions of git improve, too.
>
>> maybe we should just use
>> msgmerge with --no-location.
>
> That would partially alleviate my concerns, and I think we might be
> able to get the --add-location output back in actual checkouts with
> a "smudge" filter.

After looking at this all closer I found that these line messages really aren't that important to gettext's operation. So I'm in the process of removing them from the ab/i18n series.

I documented the new process: http://github.com/avar/git/raw/ab/i18n/po/README

Show 10 quoted lines
>> But I'd like to coordinate things on this mailing list
> [...]
>> without some external service being mandatory.
>
> No objection here. :)
>
> Of course, what is convenient for translators and maintainers (i.e.,
> not me) takes precedence anyway; I am just throwing out ideas.
>
> Thanks for your thoughtfulness.

Sure, thanks for consistently commenting on all of this. It's great to get feedback like this.

Ævar Arnfjörð Bjarmason· Sep 3, 2010, 13:01 UTC · re: Jonathan Nieder · lore

Re: [PATCH 10/25] gettextize: git-merge basic messages

On Thu, Sep 2, 2010 at 20:37, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 25 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>
>> It's on top of pu,
> [...]
>> But I was hoping that this would
>> make it into pu and after next gets released Any Day Now most of those
>> other tips in pu would be folded into next along with gettext, or at
>> least the merge conflicts wouldn't be too painful.
>
> Hmm.  That really constrains people trying to merge this series.
>
> As SubmittingPatches explains:
>
>  - In the exceptional case that a new feature depends on several topics
>   not in 'master', start working on 'next' or 'pu' privately and send
>   out patches for discussion. Before the final merge, you may have to
>   wait until some of the dependent topics graduate to 'master', and
>   rebase your work.
>
> so this is fine for discussion, but for merging, having to pull in
> _all_ topics from pu (or all topics from next for that matter) for
> the patches to apply really is a problem.
>
> Both next and pu get rewound from time to time.  They are not meant
> to be a stable basis for patches.
Junio: I've started work to rebase this whole thing on master, when
I'm done the result should be able to replace the existing ab/i18n
series you have, i.e. it won't have the Conflicts your "Merge branch
'ab/i18n'" commits have.

Also, I'm going to add a special POISON mode to Git so that we can check if changing these messages breaks anything in the test suite, basically:

    make GETTEXT_POISON=YesPlease
Which enables this in gettext.h:
    #ifdef GETTEXT_POISON
    #define _(s) "GETTEXT POISON"
    #else
    #define _(s) gettext(s)
    #endif

Which in my preliminary tests makes a bunch of tests fail, most of it is stuff like this in t0001-init.sh:

    #               grep "Initialized empty" again/out1 &&
    #               grep "Reinitialized existing" again/out2 &&
    #               >again/empty &&
    #               test_cmp again/empty again/err1 &&
    #               test_cmp again/empty again/err2

I.e. just something using the porcelain messages that are OK to translate. I'm going to add a new NO_GETTEXT_POISON test prereq to all of these, anything that remains would then indicate plumbing messages that shouldn't be translated.

Unfortunately we *don't* have complete test coverage so these sort of tests may miss something. But it should make this series a lot more robust.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 11/25] gettextize: git-merge "In-index merge" message

Make the "In-index merge" message translatable. This just emits to stdout via finish(), so translating it should be fine.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/merge.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to builtin/merge.c +1 −1
diff --git a/builtin/merge.c b/builtin/merge.c
index bf3b313..956ce14 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -791,7 +791,7 @@ static int merge_trivial(void)
 	parent->next->item = remoteheads->item;
 	parent->next->next = NULL;
 	commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL);
-	finish(result_commit, "In-index merge");
+	finish(result_commit, _("In-index merge"));
 	drop_save();
 	return 0;
 }
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 12/25] gettextize: git-merge "Merge made by %s." message

Like the "In-index merge" message "Merge made by %s." emits to stdout via finish(), so translating it should be fine.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/merge.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to builtin/merge.c +1 −1
diff --git a/builtin/merge.c b/builtin/merge.c
index 956ce14..9121c7b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -820,7 +820,7 @@ static int finish_automerge(struct commit_list *common,
 	free_commit_list(remoteheads);
 	strbuf_addch(&merge_msg, '\n');
 	commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL);
-	strbuf_addf(&buf, "Merge made by %s.", wt_strategy);
+	strbuf_addf(&buf, _("Merge made by %s."), wt_strategy);
 	finish(result_commit, buf.buf);
 	strbuf_release(&buf);
 	drop_save();
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 13/25] gettextize: git-merge remaining cmd_merge messages

Translate "Already up-to-date.", "Fast-forward", "no commit created" and other cmd_merge() messages.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/merge.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Show changes to builtin/merge.c +4 −4
diff --git a/builtin/merge.c b/builtin/merge.c
index 9121c7b..ce831bf 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1078,7 +1078,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		 * If head can reach all the merge then we are up to date.
 		 * but first the most common case of merging one remote.
 		 */
-		finish_up_to_date("Already up-to-date.");
+		finish_up_to_date(_("Already up-to-date."));
 		return 0;
 	} else if (allow_fast_forward && !remoteheads->next &&
 			!common->next &&
@@ -1095,10 +1095,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 				hex,
 				find_unique_abbrev(remoteheads->item->object.sha1,
 				DEFAULT_ABBREV));
-		strbuf_addstr(&msg, "Fast-forward");
+		strbuf_addstr(&msg, _("Fast-forward"));
 		if (have_message)
 			strbuf_addstr(&msg,
-				" (no commit created; -m option ignored)");
+				_(" (no commit created; -m option ignored)"));
 		o = peel_to_type(sha1_to_hex(remoteheads->item->object.sha1),
 			0, NULL, OBJ_COMMIT);
 		if (!o)
@@ -1156,7 +1156,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			}
 		}
 		if (up_to_date) {
-			finish_up_to_date("Already up-to-date. Yeeah!");
+			finish_up_to_date(_("Already up-to-date. Yeeah!"));
 			return 0;
 		}
 	}
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 14/25] gettextize: git-mv basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/mv.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
Show changes to builtin/mv.c +8 −8
diff --git a/builtin/mv.c b/builtin/mv.c
index cdbb094..5d99973 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -74,7 +74,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
 	newfd = hold_locked_index(&lock_file, 1);
 	if (read_cache() < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 
 	source = copy_pathspec(prefix, argv, argc, 0);
 	modes = xcalloc(argc, sizeof(enum update_mode));
@@ -100,7 +100,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 		const char *bad = NULL;
 
 		if (show_only)
-			printf("Checking rename of '%s' to '%s'\n", src, dst);
+			printf(_("Checking rename of '%s' to '%s'\n"), src, dst);
 
 		length = strlen(src);
 		if (lstat(src, &st) < 0)
@@ -120,7 +120,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
 			first = cache_name_pos(src_w_slash, len_w_slash);
 			if (first >= 0)
-				die ("Huh? %.*s is in index?",
+				die (_("Huh? %.*s is in index?"),
 						len_w_slash, src_w_slash);
 
 			first = -1 - first;
@@ -172,7 +172,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				 * check both source and destination
 				 */
 				if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
-					warning("%s; will overwrite!", bad);
+					warning(_("%s; will overwrite!"), bad);
 					bad = NULL;
 				} else
 					bad = "Cannot overwrite";
@@ -193,7 +193,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 					i--;
 				}
 			} else
-				die ("%s, source=%s, destination=%s",
+				die (_("%s, source=%s, destination=%s"),
 				     bad, src, dst);
 		}
 	}
@@ -203,10 +203,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 		enum update_mode mode = modes[i];
 		int pos;
 		if (show_only || verbose)
-			printf("Renaming %s to %s\n", src, dst);
+			printf(_("Renaming %s to %s\n"), src, dst);
 		if (!show_only && mode != INDEX &&
 				rename(src, dst) < 0 && !ignore_errors)
-			die_errno ("renaming '%s' failed", src);
+			die_errno (_("renaming '%s' failed"), src);
 
 		if (mode == WORKING_DIRECTORY)
 			continue;
@@ -220,7 +220,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 	if (active_cache_changed) {
 		if (write_cache(newfd, active_cache, active_nr) ||
 		    commit_locked_index(&lock_file))
-			die("Unable to write new index file");
+			die(_("Unable to write new index file"));
 	}
 
 	return 0;
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 15/25] gettextize: git-mv "bad" messages

Translate messages made by assigning to the "bad" char* variable.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/mv.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
Show changes to builtin/mv.c +8 −8
diff --git a/builtin/mv.c b/builtin/mv.c
index 5d99973..8c13096 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -104,13 +104,13 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 
 		length = strlen(src);
 		if (lstat(src, &st) < 0)
-			bad = "bad source";
+			bad = _("bad source");
 		else if (!strncmp(src, dst, length) &&
 				(dst[length] == 0 || dst[length] == '/')) {
-			bad = "can not move directory into itself";
+			bad = _("can not move directory into itself");
 		} else if ((src_is_dir = S_ISDIR(st.st_mode))
 				&& lstat(dst, &st) == 0)
-			bad = "cannot move directory over file";
+			bad = _("cannot move directory over file");
 		else if (src_is_dir) {
 			const char *src_w_slash = add_slash(src);
 			int len_w_slash = length + 1;
@@ -132,7 +132,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 			free((char *)src_w_slash);
 
 			if (last - first < 1)
-				bad = "source directory is empty";
+				bad = _("source directory is empty");
 			else {
 				int j, dst_len;
 
@@ -163,9 +163,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				argc += last - first;
 			}
 		} else if (cache_name_pos(src, length) < 0)
-			bad = "not under version control";
+			bad = _("not under version control");
 		else if (lstat(dst, &st) == 0) {
-			bad = "destination exists";
+			bad = _("destination exists");
 			if (force) {
 				/*
 				 * only files can overwrite each other:
@@ -175,10 +175,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 					warning(_("%s; will overwrite!"), bad);
 					bad = NULL;
 				} else
-					bad = "Cannot overwrite";
+					bad = _("Cannot overwrite");
 			}
 		} else if (string_list_has_string(&src_for_dst, dst))
-			bad = "multiple sources for the same target";
+			bad = _("multiple sources for the same target");
 		else
 			string_list_insert(&src_for_dst, dst);
 
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 16/25] gettextize: git-rm basic messages

Make the basic git-mv messages translatable, but skip things like "rm '%s'\n" and "git rm '%s'\n" for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/rm.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
Show changes to builtin/rm.c +11 −11
diff --git a/builtin/rm.c b/builtin/rm.c
index f3772c8..68656f3 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -115,19 +115,19 @@ static int check_local_mod(unsigned char *head, int index_only)
 		 */
 		if (local_changes && staged_changes) {
 			if (!index_only || !(ce->ce_flags & CE_INTENT_TO_ADD))
-				errs = error("'%s' has staged content different "
+				errs = error(_("'%s' has staged content different "
 					     "from both the file and the HEAD\n"
-					     "(use -f to force removal)", name);
+					     "(use -f to force removal)"), name);
 		}
 		else if (!index_only) {
 			if (staged_changes)
-				errs = error("'%s' has changes staged in the index\n"
+				errs = error(_("'%s' has changes staged in the index\n"
 					     "(use --cached to keep the file, "
-					     "or -f to force removal)", name);
+					     "or -f to force removal)"), name);
 			if (local_changes)
-				errs = error("'%s' has local modifications\n"
+				errs = error(_("'%s' has local modifications\n"
 					     "(use --cached to keep the file, "
-					     "or -f to force removal)", name);
+					     "or -f to force removal)"), name);
 		}
 	}
 	return errs;
@@ -168,7 +168,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	newfd = hold_locked_index(&lock_file, 1);
 
 	if (read_cache() < 0)
-		die("index file corrupt");
+		die(_("index file corrupt"));
 
 	pathspec = get_pathspec(prefix, argv);
 	refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);
@@ -191,7 +191,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 		for (i = 0; (match = pathspec[i]) != NULL ; i++) {
 			if (!seen[i]) {
 				if (!ignore_unmatch) {
-					die("pathspec '%s' did not match any files",
+					die(_("pathspec '%s' did not match any files"),
 					    match);
 				}
 			}
@@ -199,7 +199,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 				seen_any = 1;
 			}
 			if (!recursive && seen[i] == MATCHED_RECURSIVELY)
-				die("not removing '%s' recursively without -r",
+				die(_("not removing '%s' recursively without -r"),
 				    *match ? match : ".");
 		}
 
@@ -235,7 +235,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 			printf("rm '%s'\n", path);
 
 		if (remove_file_from_cache(path))
-			die("git rm: unable to remove %s", path);
+			die(_("git rm: unable to remove %s"), path);
 	}
 
 	if (show_only)
@@ -265,7 +265,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	if (active_cache_changed) {
 		if (write_cache(newfd, active_cache, active_nr) ||
 		    commit_locked_index(&lock_file))
-			die("Unable to write new index file");
+			die(_("Unable to write new index file"));
 	}
 
 	return 0;
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 17/25] builtin: use builtin.h in git-reset

---
 builtin/reset.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to builtin/reset.c +1 −1
diff --git a/builtin/reset.c b/builtin/reset.c
index 0037be4..c198b8e 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
  */
-#include "cache.h"
+#include "builtin.h"
 #include "tag.h"
 #include "object.h"
 #include "commit.h"
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 18/25] gettextize: git-reset basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/reset.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)
Show changes to builtin/reset.c +15 −15
diff --git a/builtin/reset.c b/builtin/reset.c
index c198b8e..bf69444 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -92,20 +92,20 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
 	if (reset_type == KEEP) {
 		unsigned char head_sha1[20];
 		if (get_sha1("HEAD", head_sha1))
-			return error("You do not have a valid HEAD.");
+			return error(_("You do not have a valid HEAD."));
 		if (!fill_tree_descriptor(desc, head_sha1))
-			return error("Failed to find tree of HEAD.");
+			return error(_("Failed to find tree of HEAD."));
 		nr++;
 		opts.fn = twoway_merge;
 	}
 
 	if (!fill_tree_descriptor(desc + nr - 1, sha1))
-		return error("Failed to find tree of %s.", sha1_to_hex(sha1));
+		return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));
 	if (unpack_trees(nr, desc, &opts))
 		return -1;
 	if (write_cache(newfd, active_cache, active_nr) ||
 	    commit_locked_index(lock))
-		return error("Could not write new index file.");
+		return error(_("Could not write new index file."));
 
 	return 0;
 }
@@ -115,7 +115,7 @@ static void print_new_head_line(struct commit *commit)
 	const char *hex, *body;
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
-	printf("HEAD is now at %s", hex);
+	printf(_("HEAD is now at %s"), hex);
 	body = strstr(commit->buffer, "\n\n");
 	if (body) {
 		const char *eol;
@@ -139,10 +139,10 @@ static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
 	}
 
 	if (read_cache() < 0)
-		return error("Could not read index");
+		return error(_("Could not read index"));
 
 	result = refresh_index(&the_index, (flags), NULL, NULL,
-			       "Unstaged changes after reset:") ? 1 : 0;
+			       _("Unstaged changes after reset:")) ? 1 : 0;
 	if (write_cache(fd, active_cache, active_nr) ||
 			commit_locked_index(index_lock))
 		return error ("Could not refresh index");
@@ -167,7 +167,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
 			ce = make_cache_entry(one->mode, one->sha1, one->path,
 				0, 0);
 			if (!ce)
-				die("make_cache_entry failed for path '%s'",
+				die(_("make_cache_entry failed for path '%s'"),
 				    one->path);
 			add_cache_entry(ce, ADD_CACHE_OK_TO_ADD |
 				ADD_CACHE_OK_TO_REPLACE);
@@ -222,7 +222,7 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)
 	if (!rla)
 		rla = sep = "";
 	if (snprintf(buf, size, "%s%s%s", rla, sep, action) >= size)
-		warning("Reflog action message too long: %.*s...", 50, buf);
+		warning(_("Reflog action message too long: %.*s..."), 50, buf);
 }
 
 static void die_if_unmerged_cache(int reset_type)
@@ -300,16 +300,16 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 	}
 
 	if (get_sha1(rev, sha1))
-		die("Failed to resolve '%s' as a valid ref.", rev);
+		die(_("Failed to resolve '%s' as a valid ref."), rev);
 
 	commit = lookup_commit_reference(sha1);
 	if (!commit)
-		die("Could not parse object '%s'.", rev);
+		die(_("Could not parse object '%s'."), rev);
 	hashcpy(sha1, commit->object.sha1);
 
 	if (patch_mode) {
 		if (reset_type != NONE)
-			die("--patch is incompatible with --{hard,mixed,soft}");
+			die(_("--patch is incompatible with --{hard,mixed,soft}"));
 		return interactive_reset(rev, argv + i, prefix);
 	}
 
@@ -318,9 +318,9 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 	 * affecting the working tree nor HEAD. */
 	if (i < argc) {
 		if (reset_type == MIXED)
-			warning("--mixed with paths is deprecated; use 'git reset -- <paths>' instead.");
+			warning(_("--mixed with paths is deprecated; use 'git reset -- <paths>' instead."));
 		else if (reset_type != NONE)
-			die("Cannot do %s reset with paths.",
+			die("Cannot do %s reset with paths."
 					reset_type_names[reset_type]);
 		return read_from_tree(prefix, argv + i, sha1,
 				quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
@@ -348,7 +348,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		if (reset_type == KEEP)
 			err = err || reset_index_file(sha1, MIXED, quiet);
 		if (err)
-			die("Could not reset index file to revision '%s'.", rev);
+			die(_("Could not reset index file to revision '%s'."), rev);
 	}
 
 	/* Any resets update HEAD to the head being switched to,
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 19/25] gettextize: git-reset reset_type_names messages

Make the messages in git-reset that use the reset_type_names static array to be translatable by marking the array items with N_() and using _() later.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/reset.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
Show changes to builtin/reset.c +7 −7
diff --git a/builtin/reset.c b/builtin/reset.c
index bf69444..0557688 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -30,7 +30,7 @@ static const char * const git_reset_usage[] = {
 
 enum reset_type { MIXED, SOFT, HARD, MERGE, KEEP, NONE };
 static const char *reset_type_names[] = {
-	"mixed", "soft", "hard", "merge", "keep", NULL
+	N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL
 };
 
 static char *args_to_str(const char **argv)
@@ -228,8 +228,8 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)
 static void die_if_unmerged_cache(int reset_type)
 {
 	if (is_merge() || read_cache() < 0 || unmerged_cache())
-		die("Cannot do a %s reset in the middle of a merge.",
-		    reset_type_names[reset_type]);
+		die(_("Cannot do a %s reset in the middle of a merge."),
+		    _(reset_type_names[reset_type]));
 
 }
 
@@ -320,8 +320,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		if (reset_type == MIXED)
 			warning(_("--mixed with paths is deprecated; use 'git reset -- <paths>' instead."));
 		else if (reset_type != NONE)
-			die("Cannot do %s reset with paths."
-					reset_type_names[reset_type]);
+			die(_("Cannot do %s reset with paths."),
+					_(reset_type_names[reset_type]));
 		return read_from_tree(prefix, argv + i, sha1,
 				quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
 	}
@@ -332,8 +332,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 		setup_work_tree();
 
 	if (reset_type == MIXED && is_bare_repository())
-		die("%s reset is not allowed in a bare repository",
-		    reset_type_names[reset_type]);
+		die(_("%s reset is not allowed in a bare repository"),
+		    _(reset_type_names[reset_type]));
 
 	/* Soft reset does not touch the index file nor the working tree
 	 * at all, but requires them in a good order.  Other resets reset
-- 
1.7.2.2.614.g1dc9
Peter Krefting· Sep 15, 2010, 11:17 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 19/25] gettextize: git-reset reset_type_names messages

Ævar Arnfjörð Bjarmason:
> Make the messages in git-reset that use the reset_type_names static
> array to be translatable by marking the array items with N_() and
> using _() later.

This is untranslatable for several languages. For Swedish it would suffice to move the " reset" part into the array:

> -	"mixed", "soft", "hard", "merge", "keep", NULL
> +	N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL
> };
changing it to
N_("mixed reset"), N_("soft reset"), ...
and changing this
> -		die("Cannot do a %s reset in the middle of a merge.",
> -		    reset_type_names[reset_type]);
> +		die(_("Cannot do a %s reset in the middle of a merge."),
> +		    _(reset_type_names[reset_type]));
into "... do a %s in ..", with similar changes for the others.
-- 
\\// Peter - http://www.softwolves.pp.se/
Thomas Rast· Sep 15, 2010, 15:50 UTC · re: Peter Krefting · lore

Re: [PATCH 19/25] gettextize: git-reset reset_type_names messages

Peter Krefting wrote:
Show 19 quoted lines
> This is untranslatable for several languages. For Swedish it would suffice 
> to move the " reset" part into the array:
> 
> > -	"mixed", "soft", "hard", "merge", "keep", NULL
> > +	N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL
> > };
> 
> changing it to
> 
> N_("mixed reset"), N_("soft reset"), ...
> 
> and changing this
> 
> > -		die("Cannot do a %s reset in the middle of a merge.",
> > -		    reset_type_names[reset_type]);
> > +		die(_("Cannot do a %s reset in the middle of a merge."),
> > +		    _(reset_type_names[reset_type]));
> 
> into "... do a %s in ..", with similar changes for the others.

This would still break even in English(!) if we ever introduced an arduous or extreme reset...

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 20/25] gettextize: git-tag basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/tag.c |   60 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)
Show changes to builtin/tag.c +30 −30
diff --git a/builtin/tag.c b/builtin/tag.c
index c200e1e..7870d87 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -120,12 +120,12 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn)
 	for (p = argv; *p; p++) {
 		if (snprintf(ref, sizeof(ref), "refs/tags/%s", *p)
 					>= sizeof(ref)) {
-			error("tag name too long: %.*s...", 50, *p);
+			error(_("tag name too long: %.*s..."), 50, *p);
 			had_error = 1;
 			continue;
 		}
 		if (!resolve_ref(ref, sha1, 1, NULL)) {
-			error("tag '%s' not found.", *p);
+			error(_("tag '%s' not found."), *p);
 			had_error = 1;
 			continue;
 		}
@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,
 {
 	if (delete_ref(ref, sha1, 0))
 		return 1;
-	printf("Deleted tag '%s' (was %s)\n", name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
+	printf(_("Deleted tag '%s' (was %s)\n"), name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
 	return 0;
 }
 
@@ -152,7 +152,7 @@ static int verify_tag(const char *name, const char *ref,
 	argv_verify_tag[2] = sha1_to_hex(sha1);
 
 	if (run_command_v_opt(argv_verify_tag, RUN_GIT_CMD))
-		return error("could not verify the tag '%s'", name);
+		return error(_("could not verify the tag '%s'"), name);
 	return 0;
 }
 
@@ -167,7 +167,7 @@ static int do_sign(struct strbuf *buffer)
 	if (!*signingkey) {
 		if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
 				sizeof(signingkey)) > sizeof(signingkey) - 1)
-			return error("committer info too long.");
+			return error(_("committer info too long."));
 		bracket = strchr(signingkey, '>');
 		if (bracket)
 			bracket[1] = '\0';
@@ -187,20 +187,20 @@ static int do_sign(struct strbuf *buffer)
 	args[3] = NULL;
 
 	if (start_command(&gpg))
-		return error("could not run gpg.");
+		return error(_("could not run gpg."));
 
 	if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
 		close(gpg.in);
 		close(gpg.out);
 		finish_command(&gpg);
-		return error("gpg did not accept the tag data");
+		return error(_("gpg did not accept the tag data"));
 	}
 	close(gpg.in);
 	len = strbuf_read(buffer, gpg.out, 1024);
 	close(gpg.out);
 
 	if (finish_command(&gpg) || !len || len < 0)
-		return error("gpg failed to sign the tag");
+		return error(_("gpg failed to sign the tag"));
 
 	/* Strip CR from the line endings, in case we are on Windows. */
 	for (i = j = 0; i < buffer->len; i++)
@@ -223,7 +223,7 @@ static const char tag_template[] =
 static void set_signingkey(const char *value)
 {
 	if (strlcpy(signingkey, value, sizeof(signingkey)) >= sizeof(signingkey))
-		die("signing key value too long (%.10s...)", value);
+		die(_("signing key value too long (%.10s...)"), value);
 }
 
 static int git_tag_config(const char *var, const char *value, void *cb)
@@ -269,9 +269,9 @@ static void write_tag_body(int fd, const unsigned char *sha1)
 static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)
 {
 	if (sign && do_sign(buf) < 0)
-		return error("unable to sign the tag");
+		return error(_("unable to sign the tag"));
 	if (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)
-		return error("unable to write tag file");
+		return error(_("unable to write tag file"));
 	return 0;
 }
 
@@ -286,7 +286,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 
 	type = sha1_object_info(object, NULL);
 	if (type <= OBJ_NONE)
-	    die("bad object type.");
+	    die(_("bad object type."));
 
 	header_len = snprintf(header_buf, sizeof(header_buf),
 			  "object %s\n"
@@ -299,7 +299,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 			  git_committer_info(IDENT_ERROR_ON_NO_NAME));
 
 	if (header_len > sizeof(header_buf) - 1)
-		die("tag header too big.");
+		die(_("tag header too big."));
 
 	if (!message) {
 		int fd;
@@ -308,7 +308,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 		path = git_pathdup("TAG_EDITMSG");
 		fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
 		if (fd < 0)
-			die_errno("could not create file '%s'", path);
+			die_errno(_("could not create file '%s'"), path);
 
 		if (!is_null_sha1(prev))
 			write_tag_body(fd, prev);
@@ -318,7 +318,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 
 		if (launch_editor(path, buf, NULL)) {
 			fprintf(stderr,
-			"Please supply the message using either -m or -F option.\n");
+			_("Please supply the message using either -m or -F option.\n"));
 			exit(1);
 		}
 	}
@@ -326,13 +326,13 @@ static void create_tag(const unsigned char *object, const char *tag,
 	stripspace(buf, 1);
 
 	if (!message && !buf->len)
-		die("no tag message?");
+		die(_("no tag message?"));
 
 	strbuf_insert(buf, 0, header_buf, header_len);
 
 	if (build_tag_object(buf, sign, result) < 0) {
 		if (path)
-			fprintf(stderr, "The tag message has been left in %s\n",
+			fprintf(stderr, _("The tag message has been left in %s\n"),
 				path);
 		exit(128);
 	}
@@ -425,9 +425,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 		return list_tags(argv[0], lines == -1 ? 0 : lines,
 				 with_commit);
 	if (lines != -1)
-		die("-n option is only allowed with -l.");
+		die(_("-n option is only allowed with -l."));
 	if (with_commit)
-		die("--contains option is only allowed with -l.");
+		die(_("--contains option is only allowed with -l."));
 	if (delete)
 		return for_each_tag_name(argv, delete_tag);
 	if (verify)
@@ -435,17 +435,17 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
 	if (msg.given || msgfile) {
 		if (msg.given && msgfile)
-			die("only one -F or -m option is allowed.");
+			die(_("only one -F or -m option is allowed."));
 		annotate = 1;
 		if (msg.given)
 			strbuf_addbuf(&buf, &(msg.buf));
 		else {
 			if (!strcmp(msgfile, "-")) {
 				if (strbuf_read(&buf, 0, 1024) < 0)
-					die_errno("cannot read '%s'", msgfile);
+					die_errno(_("cannot read '%s'"), msgfile);
 			} else {
 				if (strbuf_read_file(&buf, msgfile, 1024) < 0)
-					die_errno("could not open or read '%s'",
+					die_errno(_("could not open or read '%s'"),
 						msgfile);
 			}
 		}
@@ -455,20 +455,20 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
 	object_ref = argc == 2 ? argv[1] : "HEAD";
 	if (argc > 2)
-		die("too many params");
+		die(_("too many params"));
 
 	if (get_sha1(object_ref, object))
-		die("Failed to resolve '%s' as a valid ref.", object_ref);
+		die(_("Failed to resolve '%s' as a valid ref."), object_ref);
 
 	if (snprintf(ref, sizeof(ref), "refs/tags/%s", tag) > sizeof(ref) - 1)
-		die("tag name too long: %.*s...", 50, tag);
+		die(_("tag name too long: %.*s..."), 50, tag);
 	if (check_ref_format(ref))
-		die("'%s' is not a valid tag name.", tag);
+		die(_("'%s' is not a valid tag name."), tag);
 
 	if (!resolve_ref(ref, prev, 1, NULL))
 		hashclr(prev);
 	else if (!force)
-		die("tag '%s' already exists", tag);
+		die(_("tag '%s' already exists"), tag);
 
 	if (annotate)
 		create_tag(object, tag, &buf, msg.given || msgfile,
@@ -476,11 +476,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
 	lock = lock_any_ref_for_update(ref, prev, 0);
 	if (!lock)
-		die("%s: cannot lock the ref", ref);
+		die(_("%s: cannot lock the ref"), ref);
 	if (write_ref_sha1(lock, object, NULL) < 0)
-		die("%s: cannot update the ref", ref);
+		die(_("%s: cannot update the ref"), ref);
 	if (force && hashcmp(prev, object))
-		printf("Updated tag '%s' (was %s)\n", tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
+		printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
 
 	strbuf_release(&buf);
 	return 0;
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 21/25] gettextize: git-tag tag_template message

Mark the tag_template message as translatable with N_() and then use it later with _().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/tag.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Show changes to builtin/tag.c +3 −3
diff --git a/builtin/tag.c b/builtin/tag.c
index 7870d87..4841621 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -215,10 +215,10 @@ static int do_sign(struct strbuf *buffer)
 }
 
 static const char tag_template[] =
-	"\n"
+	N_("\n"
 	"#\n"
 	"# Write a tag message\n"
-	"#\n";
+	"#\n");
 
 static void set_signingkey(const char *value)
 {
@@ -313,7 +313,7 @@ static void create_tag(const unsigned char *object, const char *tag,
 		if (!is_null_sha1(prev))
 			write_tag_body(fd, prev);
 		else
-			write_or_die(fd, tag_template, strlen(tag_template));
+			write_or_die(fd, _(tag_template), strlen(_(tag_template)));
 		close(fd);
 
 		if (launch_editor(path, buf, NULL)) {
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 22/25] gettextize: git-push basic messages

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/push.c |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)
Show changes to builtin/push.c +21 −21
diff --git a/builtin/push.c b/builtin/push.c
index e655eb7..8c8d8c7 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -40,7 +40,7 @@ static void set_refspecs(const char **refs, int nr)
 			char *tag;
 			int len;
 			if (nr <= ++i)
-				die("tag shorthand without <tag>");
+				die(_("tag shorthand without <tag>"));
 			len = strlen(refs[i]) + 11;
 			if (deleterefs) {
 				tag = xmalloc(len+1);
@@ -59,7 +59,7 @@ static void set_refspecs(const char **refs, int nr)
 			strcat(delref, ref);
 			ref = delref;
 		} else if (deleterefs)
-			die("--delete only accepts plain target ref names");
+			die(_("--delete only accepts plain target ref names"));
 		add_refspec(ref);
 	}
 }
@@ -69,13 +69,13 @@ static void setup_push_tracking(void)
 	struct strbuf refspec = STRBUF_INIT;
 	struct branch *branch = branch_get(NULL);
 	if (!branch)
-		die("You are not currently on a branch.");
+		die(_("You are not currently on a branch."));
 	if (!branch->merge_nr || !branch->merge)
-		die("The current branch %s is not tracking anything.",
+		die(_("The current branch %s is not tracking anything."),
 		    branch->name);
 	if (branch->merge_nr != 1)
-		die("The current branch %s is tracking multiple branches, "
-		    "refusing to push.", branch->name);
+		die(_("The current branch %s is tracking multiple branches, "
+		    "refusing to push."), branch->name);
 	strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
 	add_refspec(refspec.buf);
 }
@@ -97,8 +97,8 @@ static void setup_default_push_refspecs(void)
 		break;
 
 	case PUSH_DEFAULT_NOTHING:
-		die("You didn't specify any refspecs to push, and "
-		    "push.default is \"nothing\".");
+		die(_("You didn't specify any refspecs to push, and "
+		    "push.default is \"nothing\"."));
 		break;
 	}
 }
@@ -117,11 +117,11 @@ static int push_with_options(struct transport *transport, int flags)
 		transport_set_option(transport, TRANS_OPT_THIN, "yes");
 
 	if (verbosity > 0)
-		fprintf(stderr, "Pushing to %s\n", transport->url);
+		fprintf(stderr, _("Pushing to %s\n"), transport->url);
 	err = transport_push(transport, refspec_nr, refspec, flags,
 			     &nonfastforward);
 	if (err != 0)
-		error("failed to push some refs to '%s'", transport->url);
+		error(_("failed to push some refs to '%s'"), transport->url);
 
 	err |= transport_disconnect(transport);
 
@@ -129,9 +129,9 @@ static int push_with_options(struct transport *transport, int flags)
 		return 0;
 
 	if (nonfastforward && advice_push_nonfastforward) {
-		fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
+		fprintf(stderr, _("To prevent you from losing history, non-fast-forward updates were rejected\n"
 				"Merge the remote changes (e.g. 'git pull') before pushing again.  See the\n"
-				"'Note about fast-forwards' section of 'git push --help' for details.\n");
+				"'Note about fast-forwards' section of 'git push --help' for details.\n"));
 	}
 
 	return 1;
@@ -146,8 +146,8 @@ static int do_push(const char *repo, int flags)
 
 	if (!remote) {
 		if (repo)
-			die("bad repository '%s'", repo);
-		die("No destination configured to push to.");
+			die(_("bad repository '%s'"), repo);
+		die(_("No destination configured to push to."));
 	}
 
 	if (remote->mirror)
@@ -155,19 +155,19 @@ static int do_push(const char *repo, int flags)
 
 	if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
 		if (!strcmp(*refspec, "refs/tags/*"))
-			return error("--all and --tags are incompatible");
-		return error("--all can't be combined with refspecs");
+			return error(_("--all and --tags are incompatible"));
+		return error(_("--all can't be combined with refspecs"));
 	}
 
 	if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
 		if (!strcmp(*refspec, "refs/tags/*"))
-			return error("--mirror and --tags are incompatible");
-		return error("--mirror can't be combined with refspecs");
+			return error(_("--mirror and --tags are incompatible"));
+		return error(_("--mirror can't be combined with refspecs"));
 	}
 
 	if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
 				(TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
-		return error("--all and --mirror are incompatible");
+		return error(_("--all and --mirror are incompatible"));
 	}
 
 	if (!refspec && !(flags & TRANSPORT_PUSH_ALL)) {
@@ -232,9 +232,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, options, push_usage, 0);
 
 	if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
-		die("--delete is incompatible with --all, --mirror and --tags");
+		die(_("--delete is incompatible with --all, --mirror and --tags"));
 	if (deleterefs && argc < 2)
-		die("--delete doesn't make sense without any refs");
+		die(_("--delete doesn't make sense without any refs"));
 
 	if (tags)
 		add_refspec("refs/tags/*");
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 23/25] builtin: use builtin.h in git-status

Change wt-status.c to include gettext.h via builtin.h. This is needed to be able to mark messages for translation.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 wt-status.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to wt-status.c +1 −0
diff --git a/wt-status.c b/wt-status.c
index 54b6b03..7716dd9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,3 +1,4 @@
+#include "builtin.h"
 #include "cache.h"
 #include "wt-status.h"
 #include "object.h"
-- 
1.7.2.2.614.g1dc9
Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 24/25] gettextize: git-status basic messages

Ripped out as-is from the "Add initial C, Shell and Perl gettext translations" patch that was part of the gettext RFC for a long time and has already been reviewed by a lot of eyeballs.

The only change is the removal of two messages that didn't really belong: _("#\t") and _("%-20s%s\n").

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 wt-status.c |  102 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 51 insertions(+), 51 deletions(-)
Show changes to wt-status.c +51 −51
diff --git a/wt-status.c b/wt-status.c
index 7716dd9..1c1a575 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -54,16 +54,16 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
 {
 	const char *c = color(WT_STATUS_HEADER, s);
 
-	color_fprintf_ln(s->fp, c, "# Unmerged paths:");
+	color_fprintf_ln(s->fp, c, _("# Unmerged paths:"));
 	if (!advice_status_hints)
 		return;
 	if (s->in_merge)
 		;
 	else if (!s->is_initial)
-		color_fprintf_ln(s->fp, c, "#   (use \"git reset %s <file>...\" to unstage)", s->reference);
+		color_fprintf_ln(s->fp, c, _("#   (use \"git reset %s <file>...\" to unstage)"), s->reference);
 	else
-		color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
-	color_fprintf_ln(s->fp, c, "#   (use \"git add/rm <file>...\" as appropriate to mark resolution)");
+		color_fprintf_ln(s->fp, c, _("#   (use \"git rm --cached <file>...\" to unstage)"));
+	color_fprintf_ln(s->fp, c, _("#   (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
 	color_fprintf_ln(s->fp, c, "#");
 }
 
@@ -71,15 +71,15 @@ static void wt_status_print_cached_header(struct wt_status *s)
 {
 	const char *c = color(WT_STATUS_HEADER, s);
 
-	color_fprintf_ln(s->fp, c, "# Changes to be committed:");
+	color_fprintf_ln(s->fp, c, _("# Changes to be committed:"));
 	if (!advice_status_hints)
 		return;
 	if (s->in_merge)
 		; /* NEEDSWORK: use "git reset --unresolve"??? */
 	else if (!s->is_initial)
-		color_fprintf_ln(s->fp, c, "#   (use \"git reset %s <file>...\" to unstage)", s->reference);
+		color_fprintf_ln(s->fp, c, _("#   (use \"git reset %s <file>...\" to unstage)"), s->reference);
 	else
-		color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
+		color_fprintf_ln(s->fp, c, _("#   (use \"git rm --cached <file>...\" to unstage)"));
 	color_fprintf_ln(s->fp, c, "#");
 }
 
@@ -89,16 +89,16 @@ static void wt_status_print_dirty_header(struct wt_status *s,
 {
 	const char *c = color(WT_STATUS_HEADER, s);
 
-	color_fprintf_ln(s->fp, c, "# Changed but not updated:");
+	color_fprintf_ln(s->fp, c, _("# Changed but not updated:"));
 	if (!advice_status_hints)
 		return;
 	if (!has_deleted)
-		color_fprintf_ln(s->fp, c, "#   (use \"git add <file>...\" to update what will be committed)");
+		color_fprintf_ln(s->fp, c, _("#   (use \"git add <file>...\" to update what will be committed)"));
 	else
-		color_fprintf_ln(s->fp, c, "#   (use \"git add/rm <file>...\" to update what will be committed)");
-	color_fprintf_ln(s->fp, c, "#   (use \"git checkout -- <file>...\" to discard changes in working directory)");
+		color_fprintf_ln(s->fp, c, _("#   (use \"git add/rm <file>...\" to update what will be committed)"));
+	color_fprintf_ln(s->fp, c, _("#   (use \"git checkout -- <file>...\" to discard changes in working directory)"));
 	if (has_dirty_submodules)
-		color_fprintf_ln(s->fp, c, "#   (commit or discard the untracked or modified content in submodules)");
+		color_fprintf_ln(s->fp, c, _("#   (commit or discard the untracked or modified content in submodules)"));
 	color_fprintf_ln(s->fp, c, "#");
 }
 
@@ -107,10 +107,10 @@ static void wt_status_print_other_header(struct wt_status *s,
 					 const char *how)
 {
 	const char *c = color(WT_STATUS_HEADER, s);
-	color_fprintf_ln(s->fp, c, "# %s files:", what);
+	color_fprintf_ln(s->fp, c, _("# %s files:"), what);
 	if (!advice_status_hints)
 		return;
-	color_fprintf_ln(s->fp, c, "#   (use \"git %s <file>...\" to include in what will be committed)", how);
+	color_fprintf_ln(s->fp, c, _("#   (use \"git %s <file>...\" to include in what will be committed)"), how);
 	color_fprintf_ln(s->fp, c, "#");
 }
 
@@ -127,18 +127,18 @@ static void wt_status_print_unmerged_data(struct wt_status *s,
 	const char *c = color(WT_STATUS_UNMERGED, s);
 	struct wt_status_change_data *d = it->util;
 	struct strbuf onebuf = STRBUF_INIT;
-	const char *one, *how = "bug";
+	const char *one, *how = _("bug");
 
 	one = quote_path(it->string, -1, &onebuf, s->prefix);
 	color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
 	switch (d->stagemask) {
-	case 1: how = "both deleted:"; break;
-	case 2: how = "added by us:"; break;
-	case 3: how = "deleted by them:"; break;
-	case 4: how = "added by them:"; break;
-	case 5: how = "deleted by us:"; break;
-	case 6: how = "both added:"; break;
-	case 7: how = "both modified:"; break;
+	case 1: how = _("both deleted:"); break;
+	case 2: how = _("added by us:"); break;
+	case 3: how = _("deleted by them:"); break;
+	case 4: how = _("added by them:"); break;
+	case 5: how = _("deleted by us:"); break;
+	case 6: how = _("both added:"); break;
+	case 7: how = _("both modified:"); break;
 	}
 	color_fprintf(s->fp, c, "%-20s%s\n", how, one);
 	strbuf_release(&onebuf);
@@ -168,11 +168,11 @@ static void wt_status_print_change_data(struct wt_status *s,
 		if (d->new_submodule_commits || d->dirty_submodule) {
 			strbuf_addstr(&extra, " (");
 			if (d->new_submodule_commits)
-				strbuf_addf(&extra, "new commits, ");
+				strbuf_addf(&extra, _("new commits, "));
 			if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
-				strbuf_addf(&extra, "modified content, ");
+				strbuf_addf(&extra, _("modified content, "));
 			if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
-				strbuf_addf(&extra, "untracked content, ");
+				strbuf_addf(&extra, _("untracked content, "));
 			strbuf_setlen(&extra, extra.len - 2);
 			strbuf_addch(&extra, ')');
 		}
@@ -186,31 +186,31 @@ static void wt_status_print_change_data(struct wt_status *s,
 	color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
 	switch (status) {
 	case DIFF_STATUS_ADDED:
-		color_fprintf(s->fp, c, "new file:   %s", one);
+		color_fprintf(s->fp, c, _("new file:   %s"), one);
 		break;
 	case DIFF_STATUS_COPIED:
-		color_fprintf(s->fp, c, "copied:     %s -> %s", one, two);
+		color_fprintf(s->fp, c, _("copied:     %s -> %s"), one, two);
 		break;
 	case DIFF_STATUS_DELETED:
-		color_fprintf(s->fp, c, "deleted:    %s", one);
+		color_fprintf(s->fp, c, _("deleted:    %s"), one);
 		break;
 	case DIFF_STATUS_MODIFIED:
-		color_fprintf(s->fp, c, "modified:   %s", one);
+		color_fprintf(s->fp, c, _("modified:   %s"), one);
 		break;
 	case DIFF_STATUS_RENAMED:
-		color_fprintf(s->fp, c, "renamed:    %s -> %s", one, two);
+		color_fprintf(s->fp, c, _("renamed:    %s -> %s"), one, two);
 		break;
 	case DIFF_STATUS_TYPE_CHANGED:
-		color_fprintf(s->fp, c, "typechange: %s", one);
+		color_fprintf(s->fp, c, _("typechange: %s"), one);
 		break;
 	case DIFF_STATUS_UNKNOWN:
-		color_fprintf(s->fp, c, "unknown:    %s", one);
+		color_fprintf(s->fp, c, _("unknown:    %s"), one);
 		break;
 	case DIFF_STATUS_UNMERGED:
-		color_fprintf(s->fp, c, "unmerged:   %s", one);
+		color_fprintf(s->fp, c, _("unmerged:   %s"), one);
 		break;
 	default:
-		die("bug: unhandled diff status %c", status);
+		die(_("bug: unhandled diff status %c"), status);
 	}
 	if (extra.len) {
 		color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "%s", extra.buf);
@@ -633,14 +633,14 @@ void wt_status_print(struct wt_status *s)
 	const char *branch_color = color(WT_STATUS_HEADER, s);
 
 	if (s->branch) {
-		const char *on_what = "On branch ";
+		const char *on_what = _("On branch ");
 		const char *branch_name = s->branch;
 		if (!prefixcmp(branch_name, "refs/heads/"))
 			branch_name += 11;
 		else if (!strcmp(branch_name, "HEAD")) {
 			branch_name = "";
 			branch_color = color(WT_STATUS_NOBRANCH, s);
-			on_what = "Not currently on any branch.";
+			on_what = _("Not currently on any branch.");
 		}
 		color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "# ");
 		color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
@@ -650,7 +650,7 @@ void wt_status_print(struct wt_status *s)
 
 	if (s->is_initial) {
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
-		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "# Initial commit");
+		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), _("# Initial commit"));
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
 	}
 
@@ -664,38 +664,38 @@ void wt_status_print(struct wt_status *s)
 		wt_status_print_submodule_summary(s, 1);  /* unstaged */
 	}
 	if (s->show_untracked_files) {
-		wt_status_print_other(s, &s->untracked, "Untracked", "add");
+		wt_status_print_other(s, &s->untracked, _("Untracked"), _("add"));
 		if (s->show_ignored_files)
-			wt_status_print_other(s, &s->ignored, "Ignored", "add -f");
+			wt_status_print_other(s, &s->ignored, _("Ignored"), _("add -f"));
 	} else if (s->commitable)
-		fprintf(s->fp, "# Untracked files not listed%s\n",
+		fprintf(s->fp, _("# Untracked files not listed%s\n"),
 			advice_status_hints
-			? " (use -u option to show untracked files)" : "");
+			? _(" (use -u option to show untracked files)") : "");
 
 	if (s->verbose)
 		wt_status_print_verbose(s);
 	if (!s->commitable) {
 		if (s->amend)
-			fprintf(s->fp, "# No changes\n");
+			fprintf(s->fp, _("# No changes\n"));
 		else if (s->nowarn)
 			; /* nothing */
 		else if (s->workdir_dirty)
-			printf("no changes added to commit%s\n",
+			printf(_("no changes added to commit%s\n"),
 				advice_status_hints
-				? " (use \"git add\" and/or \"git commit -a\")" : "");
+				? _(" (use \"git add\" and/or \"git commit -a\")") : "");
 		else if (s->untracked.nr)
-			printf("nothing added to commit but untracked files present%s\n",
+			printf(_("nothing added to commit but untracked files present%s\n"),
 				advice_status_hints
-				? " (use \"git add\" to track)" : "");
+				? _(" (use \"git add\" to track)") : "");
 		else if (s->is_initial)
 			printf("nothing to commit%s\n", advice_status_hints
-				? " (create/copy files and use \"git add\" to track)" : "");
+				? _(" (create/copy files and use \"git add\" to track)") : "");
 		else if (!s->show_untracked_files)
-			printf("nothing to commit%s\n", advice_status_hints
-				? " (use -u to show untracked files)" : "");
+			printf(_("nothing to commit%s\n"), advice_status_hints
+				? _(" (use -u to show untracked files)") : "");
 		else
-			printf("nothing to commit%s\n", advice_status_hints
-				? " (working directory clean)" : "");
+			printf(_("nothing to commit%s\n"), advice_status_hints
+				? _(" (working directory clean)") : "");
 	}
 }
 
-- 
1.7.2.2.614.g1dc9
Jonathan Nieder· Sep 2, 2010, 20:28 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 24/25] gettextize: git-status basic messages

Ævar Arnfjörð Bjarmason wrote:
> The only change is the removal of two messages that didn't really
> belong: _("#\t") and _("%-20s%s\n").

Hmm, isn't it better to let translators tweak the output format to fit their constraints? Especially 20 characters might not be enough to hold the "deleted by them" et al messages in some language.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 20:41 UTC · re: Jonathan Nieder · lore

Re: [PATCH 24/25] gettextize: git-status basic messages

On Thu, Sep 2, 2010 at 20:28, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 8 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>
>> The only change is the removal of two messages that didn't really
>> belong: _("#\t") and _("%-20s%s\n").
>
> Hmm, isn't it better to let translators tweak the output format to fit
> their constraints?  Especially 20 characters might not be enough to
> hold the "deleted by them" et al messages in some language.

Maybe, but my current mode of operation is "do it really simple and stupid now, solicit complaints later".

Eventually I'd rather just eliminate the need for tweaking stuff like that by having some va_args function that spews out "16" for that given a bunch of arguments, i.e. (pseudocode):

    int width = gimme_longest(
        _("both deleted:"),
        _("added by us:"),
        _("deleted by them:"),
        _("added by them:"),
        _("deleted by us:"),
        _("both added:"),
        _("both modified:")
    );
    char *fmt = concat("%-", width + 4, "s%s\n");
    printf(fmt, ...)
Jonathan Nieder· Sep 2, 2010, 20:47 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 24/25] gettextize: git-status basic messages

Ævar Arnfjörð Bjarmason wrote:
Show 19 quoted lines
> Maybe, but my current mode of operation is "do it really simple and
> stupid now, solicit complaints later".
> 
> Eventually I'd rather just eliminate the need for tweaking stuff like
> that by having some va_args function that spews out "16" for that
> given a bunch of arguments, i.e. (pseudocode):
> 
>     int width = gimme_longest(
>         _("both deleted:"),
>         _("added by us:"),
>         _("deleted by them:"),
>         _("added by them:"),
>         _("deleted by us:"),
>         _("both added:"),
>         _("both modified:")
>     );
> 
>     char *fmt = concat("%-", width + 4, "s%s\n");
>     printf(fmt, ...)

Using %-*s%s like that does sound nice, but then I have to wonder about the 4. Maybe the space-constrained translator would want to decrease the margin to 2.

Which is why "when the output is intended for humans, let translators do whatever they want" seems to me like the simplest principle to follow. But you're right that it doesn't matter much and we can always wait for bug reports.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 19:40 UTC · re: Ævar Arnfjörð Bjarmason · lore

[PATCH 25/25] gettextize: git-status shortstatus messages

Make the messages added in v1.7.2-rc0~54^2~1 translatable. Some of these could use the to be implemented plural support in the gettext library.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 wt-status.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Show changes to wt-status.c +6 −6
diff --git a/wt-status.c b/wt-status.c
index 1c1a575..fc377f3 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -793,13 +793,13 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 	if (!prefixcmp(branch_name, "refs/heads/"))
 		branch_name += 11;
 	else if (!strcmp(branch_name, "HEAD")) {
-		branch_name = "HEAD (no branch)";
+		branch_name = _("HEAD (no branch)");
 		branch_color_local = color(WT_STATUS_NOBRANCH, s);
 	}
 
 	branch = branch_get(s->branch + 11);
 	if (s->is_initial)
-		color_fprintf(s->fp, header_color, "Initial commit on ");
+		color_fprintf(s->fp, header_color, _("Initial commit on "));
 	if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
 		color_fprintf_ln(s->fp, branch_color_local,
 			"%s", branch_name);
@@ -814,15 +814,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 
 	color_fprintf(s->fp, header_color, " [");
 	if (!num_ours) {
-		color_fprintf(s->fp, header_color, "behind ");
+		color_fprintf(s->fp, header_color, _("behind "));
 		color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
 	} else if (!num_theirs) {
-		color_fprintf(s->fp, header_color, "ahead ");
+		color_fprintf(s->fp, header_color, _("ahead "));
 		color_fprintf(s->fp, branch_color_local, "%d", num_ours);
 	} else {
-		color_fprintf(s->fp, header_color, "ahead ");
+		color_fprintf(s->fp, header_color, _("ahead "));
 		color_fprintf(s->fp, branch_color_local, "%d", num_ours);
-		color_fprintf(s->fp, header_color, ", behind ");
+		color_fprintf(s->fp, header_color, _(", behind "));
 		color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
 	}
 
-- 
1.7.2.2.614.g1dc9
Jonathan Nieder· Sep 2, 2010, 20:25 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH 25/25] gettextize: git-status shortstatus messages

Ævar Arnfjörð Bjarmason wrote:
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -814,15 +814,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
[...]
Show 7 quoted lines
>  	} else {
> -		color_fprintf(s->fp, header_color, "ahead ");
> +		color_fprintf(s->fp, header_color, _("ahead "));
>  		color_fprintf(s->fp, branch_color_local, "%d", num_ours);
> -		color_fprintf(s->fp, header_color, ", behind ");
> +		color_fprintf(s->fp, header_color, _(", behind "));
>  		color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);

What we make those translators suffer through. :) Would it be possible to (eventually) introduce an interface vaguely like

	color_fprintf2(s->fp, "%C(ahead )%C(%d)%C(, behind )%C( %d)",
				header_color,
				branch_color_local, num_ours,
				header_color,
				branch_color_remote, num_theirs);

? I guess this would require using strbuf_expand instead of vsnprintf for %d et al.

Ævar Arnfjörð Bjarmason· Sep 2, 2010, 20:34 UTC · re: Jonathan Nieder · lore

Re: [PATCH 25/25] gettextize: git-status shortstatus messages

On Thu, Sep 2, 2010 at 20:25, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 24 quoted lines
> Ævar Arnfjörð Bjarmason wrote:
>> --- a/wt-status.c
>> +++ b/wt-status.c
>> @@ -814,15 +814,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
> [...]
>>       } else {
>> -             color_fprintf(s->fp, header_color, "ahead ");
>> +             color_fprintf(s->fp, header_color, _("ahead "));
>>               color_fprintf(s->fp, branch_color_local, "%d", num_ours);
>> -             color_fprintf(s->fp, header_color, ", behind ");
>> +             color_fprintf(s->fp, header_color, _(", behind "));
>>               color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
>
> What we make those translators suffer through. :)  Would it be possible to
> (eventually) introduce an interface vaguely like
>
>        color_fprintf2(s->fp, "%C(ahead )%C(%d)%C(, behind )%C( %d)",
>                                header_color,
>                                branch_color_local, num_ours,
>                                header_color,
>                                branch_color_remote, num_theirs);
>
> ?  I guess this would require using strbuf_expand instead of vsnprintf
> for %d et al.

Yeah, that's my eventual master plan. This color_printf() interface really needs something like that so we can reasonably translate git-status et al.

Aside from gettext that'd make using color_fprintf() much nicer. Assembling messages like this bit-by-bit is really hard to follow.

← back to recent threads