# [PATCH 0/2] More similar messages refactoring

8 messages from 2022-01-19 to 2022-02-11. Participants: Bagas Sanjaya, René Scharfe, Ævar Arnfjörð Bjarmason, Jean-Noël AVILA, Junio C Hamano.
Thread: https://gitlist.dev/t/57265

## Bagas Sanjaya, 2022-01-19 09:44

Subject: [PATCH 0/2] More similar messages refactoring
Message-ID: <20220119094445.15542-1-bagasdotme@gmail.com>
URL: https://gitlist.dev/e/20220119094445.15542-1-bagasdotme%40gmail.com

```
We came across the need to refactor message strings when we did l10n
work. So let's continue the factorization work done in [1].

[1]:
https://lore.kernel.org/git/pull.1088.v5.git.1641412944.gitgitgadget@gmail.com/

Bagas Sanjaya (2):
  sequencer: factor GIT_AUTHOR_* from message strings
  advice: refactor "action is not possible because you have unmerged
    files"

 advice.c    | 10 +++++-----
 sequencer.c | 12 ++++++------
 2 files changed, 11 insertions(+), 11 deletions(-)


base-commit: df3c41adeb212432c53d93ce6ace5d5374dc6e11
-- 
An old man doll... just what I always wanted! - Clara


```

## Bagas Sanjaya, 2022-01-19 09:44

Subject: [PATCH 1/2] sequencer: factor GIT_AUTHOR_* from message strings
Message-ID: <20220119094445.15542-2-bagasdotme@gmail.com>
URL: https://gitlist.dev/e/20220119094445.15542-2-bagasdotme%40gmail.com
In-Reply-To: <20220119094445.15542-1-bagasdotme@gmail.com>

```
Factor messages containing GIT_AUTHOR_* variable.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 sequencer.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 6abd72160c..472feb053c 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -848,17 +848,17 @@ int read_author_script(const char *path, char **name, char **email, char **date,
 	for (i = 0; i < kv.nr; i++) {
 		if (!strcmp(kv.items[i].string, "GIT_AUTHOR_NAME")) {
 			if (name_i != -2)
-				name_i = error(_("'GIT_AUTHOR_NAME' already given"));
+				name_i = error(_("'%s' already given"), "GIT_AUTHOR_NAME");
 			else
 				name_i = i;
 		} else if (!strcmp(kv.items[i].string, "GIT_AUTHOR_EMAIL")) {
 			if (email_i != -2)
-				email_i = error(_("'GIT_AUTHOR_EMAIL' already given"));
+				email_i = error(_("'%s' already given"), "GIT_AUTHOR_EMAIL");
 			else
 				email_i = i;
 		} else if (!strcmp(kv.items[i].string, "GIT_AUTHOR_DATE")) {
 			if (date_i != -2)
-				date_i = error(_("'GIT_AUTHOR_DATE' already given"));
+				date_i = error(_("'%s' already given"), "GIT_AUTHOR_DATE");
 			else
 				date_i = i;
 		} else {
@@ -867,11 +867,11 @@ int read_author_script(const char *path, char **name, char **email, char **date,
 		}
 	}
 	if (name_i == -2)
-		error(_("missing 'GIT_AUTHOR_NAME'"));
+		error(_("missing '%s'"), "GIT_AUTHOR_NAME");
 	if (email_i == -2)
-		error(_("missing 'GIT_AUTHOR_EMAIL'"));
+		error(_("missing '%s'"), "GIT_AUTHOR_EMAIL");
 	if (date_i == -2)
-		error(_("missing 'GIT_AUTHOR_DATE'"));
+		error(_("missing '%s'"), "GIT_AUTHOR_DATE");
 	if (date_i < 0 || email_i < 0 || date_i < 0 || err)
 		goto finish;
 	*name = kv.items[name_i].util;
-- 
An old man doll... just what I always wanted! - Clara


```

## Bagas Sanjaya, 2022-01-19 09:44

Subject: [PATCH 2/2] advice: refactor "action is not possible because you have unmerged files"
Message-ID: <20220119094445.15542-3-bagasdotme@gmail.com>
URL: https://gitlist.dev/e/20220119094445.15542-3-bagasdotme%40gmail.com
In-Reply-To: <20220119094445.15542-1-bagasdotme@gmail.com>

```
Factor action names (cherry-picking, committing, merging, pulling, and
reverting) out of the message string.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 advice.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/advice.c b/advice.c
index 1dfc91d176..4c72856478 100644
--- a/advice.c
+++ b/advice.c
@@ -175,15 +175,15 @@ void list_config_advices(struct string_list *list, const char *prefix)
 int error_resolve_conflict(const char *me)
 {
 	if (!strcmp(me, "cherry-pick"))
-		error(_("Cherry-picking is not possible because you have unmerged files."));
+		error(_("%s is not possible because you have unmerged files."), "Cherry-picking");
 	else if (!strcmp(me, "commit"))
-		error(_("Committing is not possible because you have unmerged files."));
+		error(_("%s is not possible because you have unmerged files."), "Commiting");
 	else if (!strcmp(me, "merge"))
-		error(_("Merging is not possible because you have unmerged files."));
+		error(_("%s is not possible because you have unmerged files."), "Merging");
 	else if (!strcmp(me, "pull"))
-		error(_("Pulling is not possible because you have unmerged files."));
+		error(_("%s is not possible because you have unmerged files."), "Pulling");
 	else if (!strcmp(me, "revert"))
-		error(_("Reverting is not possible because you have unmerged files."));
+		error(_("%s is not possible because you have unmerged files."), "Reverting");
 	else
 		error(_("It is not possible to %s because you have unmerged files."),
 			me);
-- 
An old man doll... just what I always wanted! - Clara


```

## René Scharfe, 2022-01-19 11:11

Subject: Re: [PATCH 2/2] advice: refactor "action is not possible because you have unmerged files"
Message-ID: <b49ba26e-e41b-c597-aeb4-d76c6011fbca@web.de>
URL: https://gitlist.dev/e/b49ba26e-e41b-c597-aeb4-d76c6011fbca%40web.de
In-Reply-To: <20220119094445.15542-3-bagasdotme@gmail.com>

```
Am 19.01.22 um 10:44 schrieb Bagas Sanjaya:
> Factor action names (cherry-picking, committing, merging, pulling, and
> reverting) out of the message string.
>
> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
> ---
>  advice.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/advice.c b/advice.c
> index 1dfc91d176..4c72856478 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -175,15 +175,15 @@ void list_config_advices(struct string_list *list, const char *prefix)
>  int error_resolve_conflict(const char *me)
>  {
>  	if (!strcmp(me, "cherry-pick"))
> -		error(_("Cherry-picking is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Cherry-picking");
>  	else if (!strcmp(me, "commit"))
> -		error(_("Committing is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Commiting");
>  	else if (!strcmp(me, "merge"))
> -		error(_("Merging is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Merging");
>  	else if (!strcmp(me, "pull"))
> -		error(_("Pulling is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Pulling");
>  	else if (!strcmp(me, "revert"))
> -		error(_("Reverting is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Reverting");
>  	else
>  		error(_("It is not possible to %s because you have unmerged files."),
>  			me);

That effectively reverts 8785c42532 (i18n: advice: internationalize
message for conflicts, 2016-06-17).  Why?  Having the capitalized
English present participle of the action appear somewhere in a
translated string would sure look quite foreign in some (most?)
languages.

René

```

## Ævar Arnfjörð Bjarmason, 2022-01-19 15:31

Subject: Re: [PATCH 2/2] advice: refactor "action is not possible because you have unmerged files"
Message-ID: <220119.86tudzn3i0.gmgdl@evledraar.gmail.com>
URL: https://gitlist.dev/e/220119.86tudzn3i0.gmgdl%40evledraar.gmail.com
In-Reply-To: <20220119094445.15542-3-bagasdotme@gmail.com>

```

On Wed, Jan 19 2022, Bagas Sanjaya wrote:

> Factor action names (cherry-picking, committing, merging, pulling, and
> reverting) out of the message string.
>
> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
> ---
>  advice.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/advice.c b/advice.c
> index 1dfc91d176..4c72856478 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -175,15 +175,15 @@ void list_config_advices(struct string_list *list, const char *prefix)
>  int error_resolve_conflict(const char *me)
>  {
>  	if (!strcmp(me, "cherry-pick"))
> -		error(_("Cherry-picking is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Cherry-picking");
>  	else if (!strcmp(me, "commit"))
> -		error(_("Committing is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Commiting");
>  	else if (!strcmp(me, "merge"))
> -		error(_("Merging is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Merging");
>  	else if (!strcmp(me, "pull"))
> -		error(_("Pulling is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Pulling");
>  	else if (!strcmp(me, "revert"))
> -		error(_("Reverting is not possible because you have unmerged files."));
> +		error(_("%s is not possible because you have unmerged files."), "Reverting");
>  	else
>  		error(_("It is not possible to %s because you have unmerged files."),
>  			me);

René correctly notes downthread that we shouldn't change this, we have
plenty of these in git now to make these translatable to multiple
languages.

Just a tip that if you are refactoring something like this in that way
and we should change it, this is much nicer:

	error(_("%s is not possible because you have unmerged files."),
	     !strcmp(me, "cherry-pick") ? "Cherry-picking" :
             !strcmp(me, "commit") ? "Committing" :
             [...]

I.e. if we could do your proposed de-duplication we can also
de-duplicate this whole else if chain in favor of a less verbose ternary
operation.

```

## Jean-Noël AVILA, 2022-01-19 15:42

Subject: Re: [PATCH 2/2] advice: refactor "action is not possible because you have unmerged files"
Message-ID: <3083234.G16DuhSZxH@cayenne>
URL: https://gitlist.dev/e/3083234.G16DuhSZxH%40cayenne
In-Reply-To: <20220119094445.15542-3-bagasdotme@gmail.com>

```
On Wednesday, 19 January 2022 10:44:45 CET Bagas Sanjaya wrote:
> Factor action names (cherry-picking, committing, merging, pulling, and
> reverting) out of the message string.
> 
> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
> ---
>  advice.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/advice.c b/advice.c
> index 1dfc91d176..4c72856478 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -175,15 +175,15 @@ void list_config_advices(struct string_list *list, 
const char *prefix)
>  int error_resolve_conflict(const char *me)
>  {
>  	if (!strcmp(me, "cherry-pick"))
> -		error(_("Cherry-picking is not possible because you 
have unmerged files."));
> +		error(_("%s is not possible because you have unmerged 
files."), "Cherry-picking");
>  	else if (!strcmp(me, "commit"))
> -		error(_("Committing is not possible because you have 
unmerged files."));
> +		error(_("%s is not possible because you have unmerged 
files."), "Commiting");
>  	else if (!strcmp(me, "merge"))
> -		error(_("Merging is not possible because you have 
unmerged files."));
> +		error(_("%s is not possible because you have unmerged 
files."), "Merging");
>  	else if (!strcmp(me, "pull"))
> -		error(_("Pulling is not possible because you have 
unmerged files."));
> +		error(_("%s is not possible because you have unmerged 
files."), "Pulling");
>  	else if (!strcmp(me, "revert"))
> -		error(_("Reverting is not possible because you have 
unmerged files."));
> +		error(_("%s is not possible because you have unmerged 
files."), "Reverting");
>  	else
>  		error(_("It is not possible to %s because you have 
unmerged files."),
>  			me);
> 

These strings don't qualify for factorization, because the words that you are 
extracting are English words that need to be translated. We can only extract 
words that are know to be constant, such as options, configuration, environment 
variables.

Playing grammar lego with sentences makes it impossible for translators to find 
a good translation.

JN




```

## Junio C Hamano, 2022-01-19 18:18

Subject: Re: [PATCH 2/2] advice: refactor "action is not possible because you have unmerged files"
Message-ID: <xmqqh79zoahk.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqh79zoahk.fsf%40gitster.g
In-Reply-To: <3083234.G16DuhSZxH@cayenne>

```
Jean-Noël AVILA <jn.avila@free.fr> writes:

> Playing grammar lego with sentences makes it impossible for translators to find 
> a good translation.

Well said.

Thanks.

```

## Jean-Noël AVILA, 2022-02-11 20:26

Subject: Re: [PATCH 1/2] sequencer: factor GIT_AUTHOR_* from message strings
Message-ID: <1714138.cFTly08FWO@cayenne>
URL: https://gitlist.dev/e/1714138.cFTly08FWO%40cayenne
In-Reply-To: <20220119094445.15542-2-bagasdotme@gmail.com>

```
Hi,

Note that this patch is still relevant from an i18n point of view.

If  you do not wish to propose it, I'll cherry-pick it for my next series.

Best regards,

Jean-Noël



```
