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

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

 



Às 19:27 de 23-05-2016, Vasco Almeida escreveu:
> Mark string with advice seen by the user when in detached head.
> 
> Signed-off-by: Vasco Almeida <vascomalmeida@xxxxxxx>
> ---
>  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.
--
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]