git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 07/23] builtin/replace.c: mark more strings for translation

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jul 18, 2018, 16:10 UTC
Message-ID
<20180718161101.19765-8-pclouds@gmail.com>
In-Reply-To
<20180718161101.19765-1-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/replace.c | 74 +++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 37 deletions(-)
diff --git a/builtin/replace.c b/builtin/replace.c
index 2d7abf7a43..c77b325aa1 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -54,7 +54,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
 			enum object_type obj_type, repl_type;
 
 			if (get_oid(refname, &object))
-				return error("failed to resolve '%s' as a valid ref", refname);
+				return error(_("failed to resolve '%s' as a valid ref"), refname);
 
 			obj_type = oid_object_info(the_repository, &object,
 						   NULL);
@@ -83,8 +83,8 @@ static int list_replace_refs(const char *pattern, const char *format)
 	else if (!strcmp(format, "long"))
 		data.format = REPLACE_FORMAT_LONG;
 	else
-		return error("invalid replace format '%s'\n"
-			     "valid formats are 'short', 'medium' and 'long'",
+		return error(_("invalid replace format '%s'\n"
+			       "valid formats are 'short', 'medium' and 'long'"),
 			     format);
 
 	for_each_replace_ref(the_repository, show_reference, (void *)&data);
@@ -118,7 +118,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
 		full_hex = ref.buf + base_len;
 
 		if (read_ref(ref.buf, &oid)) {
-			error("replace ref '%s' not found", full_hex);
+			error(_("replace ref '%s' not found"), full_hex);
 			had_error = 1;
 			continue;
 		}
@@ -134,7 +134,7 @@ static int delete_replace_ref(const char *name, const char *ref,
 {
 	if (delete_ref(NULL, ref, oid, 0))
 		return 1;
-	printf_ln("Deleted replace ref '%s'", name);
+	printf_ln(_("Deleted replace ref '%s'"), name);
 	return 0;
 }
 
@@ -146,12 +146,12 @@ static int check_ref_valid(struct object_id *object,
 	strbuf_reset(ref);
 	strbuf_addf(ref, "%s%s", git_replace_ref_base, oid_to_hex(object));
 	if (check_refname_format(ref->buf, 0))
-		return error("'%s' is not a valid ref name", ref->buf);
+		return error(_("'%s' is not a valid ref name"), ref->buf);
 
 	if (read_ref(ref->buf, prev))
 		oidclr(prev);
 	else if (!force)
-		return error("replace ref '%s' already exists", ref->buf);
+		return error(_("replace ref '%s' already exists"), ref->buf);
 	return 0;
 }
 
@@ -171,10 +171,10 @@ static int replace_object_oid(const char *object_ref,
 	obj_type = oid_object_info(the_repository, object, NULL);
 	repl_type = oid_object_info(the_repository, repl, NULL);
 	if (!force && obj_type != repl_type)
-		return error("Objects must be of the same type.\n"
-			     "'%s' points to a replaced object of type '%s'\n"
-			     "while '%s' points to a replacement object of "
-			     "type '%s'.",
+		return error(_("Objects must be of the same type.\n"
+			       "'%s' points to a replaced object of type '%s'\n"
+			       "while '%s' points to a replacement object of "
+			       "type '%s'."),
 			     object_ref, type_name(obj_type),
 			     replace_ref, type_name(repl_type));
 
@@ -200,10 +200,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
 	struct object_id object, repl;
 
 	if (get_oid(object_ref, &object))
-		return error("failed to resolve '%s' as a valid ref",
+		return error(_("failed to resolve '%s' as a valid ref"),
 			     object_ref);
 	if (get_oid(replace_ref, &repl))
-		return error("failed to resolve '%s' as a valid ref",
+		return error(_("failed to resolve '%s' as a valid ref"),
 			     replace_ref);
 
 	return replace_object_oid(object_ref, &object, replace_ref, &repl, force);
@@ -222,7 +222,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
 
 	fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
 	if (fd < 0)
-		return error_errno("unable to open %s for writing", filename);
+		return error_errno(_("unable to open %s for writing"), filename);
 
 	argv_array_push(&cmd.args, "--no-replace-objects");
 	argv_array_push(&cmd.args, "cat-file");
@@ -235,7 +235,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
 	cmd.out = fd;
 
 	if (run_command(&cmd))
-		return error("cat-file reported failure");
+		return error(_("cat-file reported failure"));
 	return 0;
 }
 
@@ -251,7 +251,7 @@ static int import_object(struct object_id *oid, enum object_type type,
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0)
-		return error_errno("unable to open %s for reading", filename);
+		return error_errno(_("unable to open %s for reading"), filename);
 
 	if (!raw && type == OBJ_TREE) {
 		const char *argv[] = { "mktree", NULL };
@@ -265,11 +265,11 @@ static int import_object(struct object_id *oid, enum object_type type,
 
 		if (start_command(&cmd)) {
 			close(fd);
-			return error("unable to spawn mktree");
+			return error(_("unable to spawn mktree"));
 		}
 
 		if (strbuf_read(&result, cmd.out, 41) < 0) {
-			error_errno("unable to read from mktree");
+			error_errno(_("unable to read from mktree"));
 			close(fd);
 			close(cmd.out);
 			return -1;
@@ -278,11 +278,11 @@ static int import_object(struct object_id *oid, enum object_type type,
 
 		if (finish_command(&cmd)) {
 			strbuf_release(&result);
-			return error("mktree reported failure");
+			return error(_("mktree reported failure"));
 		}
 		if (get_oid_hex(result.buf, oid) < 0) {
 			strbuf_release(&result);
-			return error("mktree did not return an object name");
+			return error(_("mktree did not return an object name"));
 		}
 
 		strbuf_release(&result);
@@ -291,12 +291,12 @@ static int import_object(struct object_id *oid, enum object_type type,
 		int flags = HASH_FORMAT_CHECK | HASH_WRITE_OBJECT;
 
 		if (fstat(fd, &st) < 0) {
-			error_errno("unable to fstat %s", filename);
+			error_errno(_("unable to fstat %s"), filename);
 			close(fd);
 			return -1;
 		}
 		if (index_fd(oid, fd, &st, type, NULL, flags) < 0)
-			return error("unable to write object to database");
+			return error(_("unable to write object to database"));
 		/* index_fd close()s fd for us */
 	}
 
@@ -315,11 +315,11 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
 	struct strbuf ref = STRBUF_INIT;
 
 	if (get_oid(object_ref, &old_oid) < 0)
-		return error("not a valid object name: '%s'", object_ref);
+		return error(_("not a valid object name: '%s'"), object_ref);
 
 	type = oid_object_info(the_repository, &old_oid, NULL);
 	if (type < 0)
-		return error("unable to get object type for %s",
+		return error(_("unable to get object type for %s"),
 			     oid_to_hex(&old_oid));
 
 	if (check_ref_valid(&old_oid, &prev, &ref, force)) {
@@ -335,7 +335,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
 	}
 	if (launch_editor(tmpfile, NULL, NULL) < 0) {
 		free(tmpfile);
-		return error("editing object file failed");
+		return error(_("editing object file failed"));
 	}
 	if (import_object(&new_oid, type, raw, tmpfile)) {
 		free(tmpfile);
@@ -344,7 +344,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
 	free(tmpfile);
 
 	if (!oidcmp(&old_oid, &new_oid))
-		return error("new object is the same as the old one: '%s'", oid_to_hex(&old_oid));
+		return error(_("new object is the same as the old one: '%s'"), oid_to_hex(&old_oid));
 
 	return replace_object_oid(object_ref, &old_oid, "replacement", &new_oid, force);
 }
@@ -476,10 +476,10 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
 
 	if (!oidcmp(&old_oid, &new_oid)) {
 		if (gentle) {
-			warning("graft for '%s' unnecessary", oid_to_hex(&old_oid));
+			warning(_("graft for '%s' unnecessary"), oid_to_hex(&old_oid));
 			return 0;
 		}
-		return error("new commit is the same as the old one: '%s'", oid_to_hex(&old_oid));
+		return error(_("new commit is the same as the old one: '%s'"), oid_to_hex(&old_oid));
 	}
 
 	return replace_object_oid(old_ref, &old_oid, "replacement", &new_oid, force);
@@ -553,7 +553,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 		cmdmode = argc ? MODE_REPLACE : MODE_LIST;
 
 	if (format && cmdmode != MODE_LIST)
-		usage_msg_opt("--format cannot be used when not listing",
+		usage_msg_opt(_("--format cannot be used when not listing"),
 			      git_replace_usage, options);
 
 	if (force &&
@@ -561,47 +561,47 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 	    cmdmode != MODE_EDIT &&
 	    cmdmode != MODE_GRAFT &&
 	    cmdmode != MODE_CONVERT_GRAFT_FILE)
-		usage_msg_opt("-f only makes sense when writing a replacement",
+		usage_msg_opt(_("-f only makes sense when writing a replacement"),
 			      git_replace_usage, options);
 
 	if (raw && cmdmode != MODE_EDIT)
-		usage_msg_opt("--raw only makes sense with --edit",
+		usage_msg_opt(_("--raw only makes sense with --edit"),
 			      git_replace_usage, options);
 
 	switch (cmdmode) {
 	case MODE_DELETE:
 		if (argc < 1)
-			usage_msg_opt("-d needs at least one argument",
+			usage_msg_opt(_("-d needs at least one argument"),
 				      git_replace_usage, options);
 		return for_each_replace_name(argv, delete_replace_ref);
 
 	case MODE_REPLACE:
 		if (argc != 2)
-			usage_msg_opt("bad number of arguments",
+			usage_msg_opt(_("bad number of arguments"),
 				      git_replace_usage, options);
 		return replace_object(argv[0], argv[1], force);
 
 	case MODE_EDIT:
 		if (argc != 1)
-			usage_msg_opt("-e needs exactly one argument",
+			usage_msg_opt(_("-e needs exactly one argument"),
 				      git_replace_usage, options);
 		return edit_and_replace(argv[0], force, raw);
 
 	case MODE_GRAFT:
 		if (argc < 1)
-			usage_msg_opt("-g needs at least one argument",
+			usage_msg_opt(_("-g needs at least one argument"),
 				      git_replace_usage, options);
 		return create_graft(argc, argv, force, 0);
 
 	case MODE_CONVERT_GRAFT_FILE:
 		if (argc != 0)
-			usage_msg_opt("--convert-graft-file takes no argument",
+			usage_msg_opt(_("--convert-graft-file takes no argument"),
 				      git_replace_usage, options);
 		return !!convert_graft_file(force);
 
 	case MODE_LIST:
 		if (argc > 1)
-			usage_msg_opt("only one pattern can be given with -l",
+			usage_msg_opt(_("only one pattern can be given with -l"),
 				      git_replace_usage, options);
 		return list_replace_refs(argv[0], format);
 
-- 
2.18.0.rc2.476.g39500d3211
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 18 of 58 in “Mark strings for translation”
  1. 00/23 Mark strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  2. 02/23 archive-tar.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  3. Junio C HamanoJul 19, 2018
  4. Duy NguyenJul 21, 2018
  5. 03/23 archive-zip.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  6. Junio C HamanoJul 19, 2018
  7. Duy NguyenJul 19, 2018
  8. Junio C HamanoJul 19, 2018
  9. 01/23 Update messages in preparation for i18nNguyễn Thái Ngọc Duy, Jul 18, 2018
  10. Junio C HamanoJul 19, 2018
  11. Junio C HamanoJul 19, 2018
  12. Duy NguyenJul 21, 2018
  13. 04/23 builtin/config.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  14. 05/23 builtin/grep.c: mark strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  15. 06/23 builtin/pack-objects.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  16. Junio C HamanoJul 19, 2018
  17. 08/23 commit-graph.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  18. 07/23 builtin/replace.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  19. 09/23 config.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  20. 10/23 connect.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  21. Junio C HamanoJul 19, 2018
  22. 11/23 convert.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  23. 13/23 environment.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  24. 12/23 dir.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  25. 14/23 exec-cmd.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  26. 15/23 object.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  27. 16/23 pkt-line.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  28. 17/23 refs.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  29. 18/23 refspec.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  30. 19/23 replace-object.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  31. 20/23 sequencer.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  32. 21/23 sha1-file.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  33. 22/23 transport.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  34. 23/23 transport-helper.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 18, 2018
  35. 00/23 Mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  36. 01/23 Update messages in preparation for i18nNguyễn Thái Ngọc Duy, Jul 21, 2018
  37. 05/23 builtin/grep.c: mark strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  38. 03/23 archive-zip.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  39. 04/23 builtin/config.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  40. 06/23 builtin/pack-objects.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  41. 08/23 commit-graph.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  42. 07/23 builtin/replace.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  43. 10/23 connect.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  44. 12/23 dir.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  45. 13/23 environment.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  46. 15/23 object.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  47. 14/23 exec-cmd.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  48. 11/23 convert.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  49. 16/23 pkt-line.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  50. 18/23 refspec.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  51. 19/23 replace-object.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  52. 20/23 sequencer.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  53. 17/23 refs.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  54. 21/23 sha1-file.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  55. 22/23 transport.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  56. 23/23 transport-helper.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  57. 09/23 config.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018
  58. 02/23 archive-tar.c: mark more strings for translationNguyễn Thái Ngọc Duy, Jul 21, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.