Thread (27 messages) flat view 27 messages, 2 authors, 2016-06-16

Re: [PATCH v2 02/22] i18n: advice: mark string about detached head for translation

From: Vasco Almeida <hidden>
Date: 2016-06-16 02:19:39

Às 19:27 de 23-05-2016, Vasco Almeida escreveu:
quoted hunk ↗ jump to hunk
Mark string with advice seen by the user when in detached head.

Signed-off-by: Vasco Almeida <redacted>
---
 advice.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/advice.c b/advice.c
index 4dc5cf1..703a847 100644
--- a/advice.c
+++ b/advice.c
@@ -107,13 +107,13 @@ void NORETURN die_conclude_merge(void)
 void detach_advice(const char *new_name)
 {
 	const char fmt[] =
-	"Note: checking out '%s'.\n\n"
+	N_("Note: checking out '%s'.\n\n"
 	"You are in 'detached HEAD' state. You can look around, make experimental\n"
 	"changes and commit them, and you can discard any commits you make in this\n"
 	"state without impacting any branches by performing another checkout.\n\n"
 	"If you want to create a new branch to retain commits you create, you may\n"
 	"do so (now or later) by using -b with the checkout command again. Example:\n\n"
-	"  git checkout -b <new-branch-name>\n\n";
+	"  git checkout -b <new-branch-name>\n\n");
 
 	fprintf(stderr, fmt, new_name);
 }
I just realized this does nothing but letting xgettext extract the
string. Does not allow interpolating the actual translation. Hence, the
translator would translate this text but the translation would never be
used.

There are 2 solutions: 1) use const char *fmt = _("...") instead
2) still use N_() like this patch but do fprintf(stderr, _(fmt),
new_name); to trigger retrieving the translation when printing the message.

Option 1) it most common on git source and 2) is used primarily during
command line option parse (see usage_with_options_internal() in
parse-options.c).

I prefer the solution 1) and I'll choose it if there are no objections.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help