Re: [PATCH v4 16/73] gettextize: git-branch "remote branch '%s' not found" message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



W dniu 23.02.2011 00:41, Ãvar ArnfjÃrà Bjarmason pisze:
> 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.

Not sure what you meant by splitting it up. Hopefully not splitting the
text even more?

IMO all such code will have to be rewritten to allow better translation.
Example patch at the bottom.

I remember at least one more such case - it was sth like "%s %s %s" where
first part was translatable but defined somewhere else.

This can be done before or after applying the i18n patches, but if it's going
to be done after, then I think it'd be better to mark such places as "to be
rewritten" instead of just simply marking them for translation.

> 
> Signed-off-by: Ãvar ArnfjÃrà Bjarmason <avarab@xxxxxxxxx>
> ---
>  builtin/branch.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 6695db4..e9d8a5a 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:


--->8---
>From a82add2f0562839e60611e7c3f3409d6cea87ad1 Mon Sep 17 00:00:00 2001
From: Piotr Krukowiecki <piotr.krukowiecki@xxxxxxxxx>
Date: Sun, 27 Feb 2011 19:55:48 +0100
Subject: [PATCH] Change how error message is created for easier translation

When a text is split or stiched together from several
texts it's very hard/impossible to do a good translation.

Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@xxxxxxxxx>
---
 builtin/branch.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index fe8f2fc..e4adc34 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -149,20 +149,20 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 	struct commit *rev, *head_rev = NULL;
 	unsigned char sha1[20];
 	char *name = NULL;
-	const char *fmt, *remote;
+	const char *fmt;
 	int i;
 	int ret = 0;
 	struct strbuf bname = STRBUF_INIT;
+	int is_remote = 0;
 
 	switch (kinds) {
 	case REF_REMOTE_BRANCH:
 		fmt = "refs/remotes/%s";
-		remote = "remote ";
+		is_remote = 1;
 		force = 1;
 		break;
 	case REF_LOCAL_BRANCH:
 		fmt = "refs/heads/%s";
-		remote = "";
 		break;
 	default:
 		die("cannot use -a with -d");
@@ -186,8 +186,9 @@ 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.",
-					remote, bname.buf);
+			const char *error_str = is_remote ? "Remote branch '%s' not found." :
+				"Branch '%s' not found.";
+			error(error_str, bname.buf);
 			ret = 1;
 			continue;
 		}
@@ -208,12 +209,15 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 		}
 
 		if (delete_ref(name, sha1, 0)) {
-			error("Error deleting %sbranch '%s'", remote,
-			      bname.buf);
+			const char *error_str = is_remote ? "Error deleting remote branch '%s'" :
+				"Error deleting branch '%s'";
+			error(error_str, bname.buf);
 			ret = 1;
 		} else {
 			struct strbuf buf = STRBUF_INIT;
-			printf("Deleted %sbranch %s (was %s).\n", remote,
+			const char *error_str = is_remote ? "Deleted remote branch %s (was %s).\n" :
+				"Deleted branch %s (was %s).\n";
+			printf(error_str,
 			       bname.buf,
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
 			strbuf_addf(&buf, "branch.%s", bname.buf);
-- 
1.7.1


-- 
Piotr Krukowiecki
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]