threads / patch / 37498

patch, 2 partsi18n translate builtin warning, error, usage, fatal messages

Subject: [PATCH 2/2] i18n translate builtin warning, error, usage, fatal messages

## tl;dr

4 messages between Sep 5, 2014 and Sep 5, 2014. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Sandy Carter· Sep 5, 2014, 18:57 UTC · lore

[PATCH 0/2] Translations for ambiguous refname warning

Here is a pair of commit which allow messages from git to be translated when running an ambiguous checkout such as when a branch name and a tag name are the same.

Sandy Carter (2):
  i18n: ambiguous refname message is not translated
  i18n translate builtin warning, error, usage, fatal messages
 sha1_name.c | 6 +++---
 usage.c     | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
Sandy Carter· Sep 5, 2014, 18:57 UTC · re: Sandy Carter · lore

[PATCH 1/2] i18n: ambiguous refname message is not translated

Allow warning message about ambuiguous refname to be exported to .pot files when checking out a refname which is the name of a tag and of a branch for example.

Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
---
 sha1_name.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Show changes to sha1_name.c +3 −3
diff --git a/sha1_name.c b/sha1_name.c
index 63ee66f..6571287 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -434,7 +434,7 @@ static int interpret_nth_prior_checkout(const char *name, int namelen, struct st
 
 static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 {
-	static const char *warn_msg = "refname '%.*s' is ambiguous.";
+	static const char *warn_msg = N_("refname '%.*s' is ambiguous.");
 	static const char *object_name_msg = N_(
 	"Git normally never creates a ref that ends with 40 hex characters\n"
 	"because it will be ignored when you just specify 40-hex. These refs\n"
@@ -454,7 +454,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 		if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
 			refs_found = dwim_ref(str, len, tmp_sha1, &real_ref);
 			if (refs_found > 0) {
-				warning(warn_msg, len, str);
+				warning(_(warn_msg), len, str);
 				if (advice_object_name_warning)
 					fprintf(stderr, "%s\n", _(object_name_msg));
 			}
@@ -514,7 +514,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 	if (warn_ambiguous_refs &&
 	    (refs_found > 1 ||
 	     !get_short_sha1(str, len, tmp_sha1, GET_SHA1_QUIETLY)))
-		warning(warn_msg, len, str);
+		warning(_(warn_msg), len, str);
 
 	if (reflog_len) {
 		int nth, i;
-- 
2.1.0
Sandy Carter· Sep 5, 2014, 18:57 UTC · re: Sandy Carter · lore

Allow warnings, errors, usage and fatal messages to be translated to user when checking out a ambiguous refname for example

Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
---
 usage.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Show changes to usage.c +4 −4
diff --git a/usage.c b/usage.c
index ed14645..24a450e 100644
--- a/usage.c
+++ b/usage.c
@@ -27,24 +27,24 @@ void vwritef(int fd, const char *prefix, const char *err, va_list params)
 
 static NORETURN void usage_builtin(const char *err, va_list params)
 {
-	vreportf("usage: ", err, params);
+	vreportf(_("usage: "), err, params);
 	exit(129);
 }
 
 static NORETURN void die_builtin(const char *err, va_list params)
 {
-	vreportf("fatal: ", err, params);
+	vreportf(_("fatal: "), err, params);
 	exit(128);
 }
 
 static void error_builtin(const char *err, va_list params)
 {
-	vreportf("error: ", err, params);
+	vreportf(_("error: "), err, params);
 }
 
 static void warn_builtin(const char *warn, va_list params)
 {
-	vreportf("warning: ", warn, params);
+	vreportf(_("warning: "), warn, params);
 }
 
 static int die_is_recursing_builtin(void)
-- 
2.1.0
Junio C Hamano· Sep 5, 2014, 19:47 UTC · re: Sandy Carter · lore

Re: [PATCH 2/2] i18n translate builtin warning, error, usage, fatal messages

Sandy Carter <sandy.carter@savoirfairelinux.com> writes:
Show 5 quoted lines
> Allow warnings, errors, usage and fatal messages to be translated to user
> when checking out a ambiguous refname for example
>
> Signed-off-by: Sandy Carter <sandy.carter@savoirfairelinux.com>
> ---

Hmmmm. Doesn't this break the plumbing commands whose messages are meant to be matched and interpreted by scripts?

Show 36 quoted lines
>  usage.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/usage.c b/usage.c
> index ed14645..24a450e 100644
> --- a/usage.c
> +++ b/usage.c
> @@ -27,24 +27,24 @@ void vwritef(int fd, const char *prefix, const char *err, va_list params)
>  
>  static NORETURN void usage_builtin(const char *err, va_list params)
>  {
> -	vreportf("usage: ", err, params);
> +	vreportf(_("usage: "), err, params);
>  	exit(129);
>  }
>  
>  static NORETURN void die_builtin(const char *err, va_list params)
>  {
> -	vreportf("fatal: ", err, params);
> +	vreportf(_("fatal: "), err, params);
>  	exit(128);
>  }
>  
>  static void error_builtin(const char *err, va_list params)
>  {
> -	vreportf("error: ", err, params);
> +	vreportf(_("error: "), err, params);
>  }
>  
>  static void warn_builtin(const char *warn, va_list params)
>  {
> -	vreportf("warning: ", warn, params);
> +	vreportf(_("warning: "), warn, params);
>  }
>  
>  static int die_is_recursing_builtin(void)

← back to recent threads