git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 24/39] i18n: bisect: enable l10n of bisect terms in messages

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 2, 2016, 17:33 UTC
Message-ID
<xmqqbn3jv6ka.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<574FF6A6.8030609@sapo.pt>
Vasco Almeida <vascomalmeida@sapo.pt> writes:
Show 11 quoted lines
> Às 17:38 de 01-06-2016, Junio C Hamano escreveu:
>> Vasco Almeida <vascomalmeida@sapo.pt> writes:
>> 
>>> +enum term { BAD, GOOD, OLD, NEW };
>>> +static const char *term_names[] = {
>>> +/* TRANSLATORS: in bisect.c source code file, the following terms are
>>> +   used to describe a "bad commit", "good commit", "new revision", etc.
>>> +   Please, if you can, check the source when you are not sure if a %s
>>> +   would be replaced by one of the following terms. */
>>> +	N_("bad"), N_("good"), N_("old"), N_("new"),  NULL
>>> +};
As you pointed out (below), I _did_ misread these N_() ...
Show 15 quoted lines
>>>  /* Remember to update object flag allocation in object.h */
>>>  #define COUNTED		(1u<<16)
>>>  
>>> @@ -725,12 +734,12 @@ static void handle_bad_merge_base(void)
>>>  	if (is_expected_rev(current_bad_oid)) {
>>>  		char *bad_hex = oid_to_hex(current_bad_oid);
>>>  		char *good_hex = join_sha1_array_hex(&good_revs, ' ');
>>> -		if (!strcmp(term_bad, "bad") && !strcmp(term_good, "good")) {
>>> +		if (!strcmp(term_bad, term_names[BAD]) && !strcmp(term_good, term_names[GOOD])) {
>>>  			fprintf(stderr, _("The merge base %s is bad.\n"
>>>  				"This means the bug has been fixed "
>>>  				"between %s and [%s].\n"),
>>>  				bad_hex, bad_hex, good_hex);
>>> -		} else if (!strcmp(term_bad, "new") && !strcmp(term_good, "old")) {
>>> +		} else if (!strcmp(term_bad, term_names[NEW]) && !strcmp(term_good, term_names[OLD])) {

... which means the above two changes are "since we have these four word constants in an array up there, let's use them", i.e. there is no change in behaviour when running the program in any locale, but it is a good programming practice (as long as the term_names[] array that holds the four word constants and indexes into it with enum term is justifiable, that is).

Show 6 quoted lines
>>> @@ -739,7 +748,7 @@ static void handle_bad_merge_base(void)
>>>  			fprintf(stderr, _("The merge base %s is %s.\n"
>>>  				"This means the first '%s' commit is "
>>>  				"between %s and [%s].\n"),
>>> -				bad_hex, term_bad, term_good, bad_hex, good_hex);
>>> +				bad_hex, _(term_bad), _(term_good), bad_hex, good_hex);
But this translation still does not make much sense to me.

If the user did not change term_bad and term_good from the default ones (i.e. the four words above), the flow of control would not come here; one of the above two !strcmp() lines you changed would trigger.

On the other hand, if the user did change term_bad and term_good by using --term-old=velho --term-new=novo earlier (which is stored in BISECT_TERMS and read into these two variables), these are strings that Git encounters at runtime; you cannot expect _(term_bad) aka _("novo") to be translated by *.po files for the locale.

And even if it were somehow translatable, you do not want to.

Imagine a case where there is a Portuguese word the user used in place of 'novo' in the example above, and there is an English word with the same spelling with a totally different meaning. And further imagine that English word is used elsewhere in Git and has translation to Portuguese in your *.po file. _(term_bad) would become a translation of that English word into Portuguese, which would be a word totally unrelated to the word the user used originally when she did --term-old=<that word in portuguese>.

So I do not think _(term_bad) and _(term_good) is a good idea in the last hunk quoted above (it is not just "not a good idea", but actually would be harmful), which would make term_names[] and "enum term" unnecessary.

There is a case where one of the default four words could seep through to the last else clause. Is that what you are trying to address?

That is, when term_bad is left as "bad" but term_good is customized to "super", neither "term_bad is 'bad' and term_good is 'good'" nor "term_bad is 'new' and term_good is 'old" is true, and we would say

	Merge base is BAD.  This means the first SUPER commit is ...

With your change to mark _(term_bad) and _(term_good), the message would translate term_bad to whatever word it is in your language, and term_good that comes from the end user will be left as SUPER as the user typed. I am not sure if it is a good thing to translate only BAD while leaving SUPER as-is in such a case.

Previous: Vasco AlmeidaNext: Vasco Almeida
Message 31 of 50 in “i18n and test updates”
  1. 00/39 i18n and test updatesVasco Almeida, Jun 1, 2016
  2. 01/39 i18n: builtin/remote.c: fix mark for translationVasco Almeida, Jun 1, 2016
  3. 02/39 i18n: advice: mark string about detached head for translationVasco Almeida, Jun 1, 2016
  4. 03/39 i18n: advice: internationalize message for conflictsVasco Almeida, Jun 1, 2016
  5. 04/39 i18n: transport: mark strings for translationVasco Almeida, Jun 1, 2016
  6. 05/39 i18n: sequencer: mark entire sentences for translationVasco Almeida, Jun 1, 2016
  7. 06/39 i18n: sequencer: mark string for translationVasco Almeida, Jun 1, 2016
  8. 07/39 i18n: merge-octopus: mark messages for translationVasco Almeida, Jun 1, 2016
  9. 08/39 merge-octupus: use die shell function from git-sh-setup.shVasco Almeida, Jun 1, 2016
  10. 09/39 i18n: rebase: fix marked string to use eval_gettext variantVasco Almeida, Jun 1, 2016
  11. 10/39 i18n: rebase: mark placeholder for translationVasco Almeida, Jun 1, 2016
  12. 11/39 i18n: bisect: simplify error message for i18nVasco Almeida, Jun 1, 2016
  13. 12/39 t6030: update to use test_i18ncmpVasco Almeida, Jun 1, 2016
  14. 13/39 i18n: git-sh-setup.sh: mark strings for translationVasco Almeida, Jun 1, 2016
  15. Junio C HamanoJun 1, 2016
  16. Junio C HamanoJun 1, 2016
  17. Vasco AlmeidaJun 2, 2016
  18. 14/39 i18n: rebase-interactive: mark strings for translationVasco Almeida, Jun 1, 2016
  19. 15/39 i18n: rebase-interactive: mark here-doc strings for translationVasco Almeida, Jun 1, 2016
  20. 16/39 i18n: rebase-interactive: mark comments of squash for translationVasco Almeida, Jun 1, 2016
  21. 17/39 i18n: setup: mark strings for translationVasco Almeida, Jun 1, 2016
  22. 18/39 tests: use test_i18n* functions to suppress false positivesVasco Almeida, Jun 1, 2016
  23. 19/39 tests: unpack-trees: update to use test_i18n* functionsVasco Almeida, Jun 1, 2016
  24. 20/39 t9003: become resilient to GETTEXT_POISONVasco Almeida, Jun 1, 2016
  25. 21/39 t4153: fix negated test_i18ngrep callVasco Almeida, Jun 1, 2016
  26. 22/39 t5523: use test_i18ngrep for negationVasco Almeida, Jun 1, 2016
  27. 23/39 i18n: bisect: mark strings for translationVasco Almeida, Jun 1, 2016
  28. 24/39 i18n: bisect: enable l10n of bisect terms in messagesVasco Almeida, Jun 1, 2016
  29. Junio C HamanoJun 1, 2016
  30. Vasco AlmeidaJun 2, 2016
  31. Junio C HamanoJun 2, 2016
  32. Vasco AlmeidaJun 3, 2016
  33. 25/39 i18n: transport-helper.c: change N_() call to _()Vasco Almeida, Jun 1, 2016
  34. 26/39 i18n: notes: mark strings for translationVasco Almeida, Jun 1, 2016
  35. 27/39 i18n: notes: mark options for translationVasco Almeida, Jun 1, 2016
  36. 28/39 i18n: config: unfold error messages marked for translationVasco Almeida, Jun 1, 2016
  37. Junio C HamanoJun 1, 2016
  38. Vasco AlmeidaJun 2, 2016
  39. Junio C HamanoJun 2, 2016
  40. 29/39 i18n: merge: mark messages for translationVasco Almeida, Jun 1, 2016
  41. 30/39 i18n: merge: change command option help to lowercaseVasco Almeida, Jun 1, 2016
  42. 31/39 i18n: sequencer: add period to error messageVasco Almeida, Jun 1, 2016
  43. 32/39 i18n: standardise messagesVasco Almeida, Jun 1, 2016
  44. 33/39 i18n: remote: mark URL fallback text for translationVasco Almeida, Jun 1, 2016
  45. 34/39 i18n: remote: allow translations to reorder messageVasco Almeida, Jun 1, 2016
  46. 35/39 i18n: init-db: join message piecesVasco Almeida, Jun 1, 2016
  47. 36/39 i18n: submodule: join strings marked for translationVasco Almeida, Jun 1, 2016
  48. 37/39 i18n: submodule: escape shell variables inside eval_gettextVasco Almeida, Jun 1, 2016
  49. 38/39 i18n: unmark die messages for translationVasco Almeida, Jun 1, 2016
  50. 39/39 i18n: branch: mark comment when editing branch description for translationVasco Almeida, Jun 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.