i18n: Fix translation of --help [PR93759]

Message ID 20200217232743.GP2155@tucnak
State New
Headers show
Series
  • i18n: Fix translation of --help [PR93759]
Related show

Commit Message

Jakub Jelinek Feb. 17, 2020, 11:27 p.m.
Hi!

The first two hunks make sure we actually translate what has been marked
for translation, i.e. the cl_options[...].help strings, rather than those
strings ammended in various ways, like:
_("%s  Same as %s."), help, ...
or
"%s  %s", help, _(use_diagnosed_msg)

The exgettext changes attempt to make sure that the cl_options[...].help
strings are marked as no-c-format, because otherwise if they happen
to contain a % character, such as the 90% substring, they will be marked
as c-format, which they aren't.

Bootstrapped/regtested on x86_64-linux and i686-linux plus tested with make
gcc.pot, ok for trunk?

2020-02-17  Jakub Jelinek  <jakub@redhat.com>

	PR translation/93759
	* opts.c (print_filtered_help): Translate help before appending
	messages to it rather than after that.

	* exgettext: For *.opt help texts, use __opt_help_text("...")
	rather than _("...") in the $emsg file and pass options that
	say that this implies no-c-format.


	Jakub

Comments

Joseph Myers Feb. 18, 2020, 8:29 p.m. | #1
On Tue, 18 Feb 2020, Jakub Jelinek wrote:

> Hi!

> 

> The first two hunks make sure we actually translate what has been marked

> for translation, i.e. the cl_options[...].help strings, rather than those

> strings ammended in various ways, like:

> _("%s  Same as %s."), help, ...

> or

> "%s  %s", help, _(use_diagnosed_msg)

> 

> The exgettext changes attempt to make sure that the cl_options[...].help

> strings are marked as no-c-format, because otherwise if they happen

> to contain a % character, such as the 90% substring, they will be marked

> as c-format, which they aren't.

> 

> Bootstrapped/regtested on x86_64-linux and i686-linux plus tested with make

> gcc.pot, ok for trunk?


OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

Patch

--- gcc/opts.c.jj	2020-01-27 13:20:40.491649814 +0100
+++ gcc/opts.c	2020-02-17 14:52:56.164212999 +0100
@@ -1309,10 +1309,13 @@  print_filtered_help (unsigned int includ
 	  help = undocumented_msg;
 	}
 
+      /* Get the translation.  */
+      help = _(help);
+
       if (option->alias_target < N_OPTS
 	  && cl_options [option->alias_target].help)
 	{
-	  if (help == undocumented_msg)
+	  if (option->help == NULL)
 	    {
 	      /* For undocumented options that are aliases for other options
 		 that are documented, point the reader to the other option in
@@ -1347,9 +1350,6 @@  print_filtered_help (unsigned int includ
 	  help = new_help;
 	}
 
-      /* Get the translation.  */
-      help = _(help);
-
       /* Find the gap between the name of the
 	 option and its descriptive text.  */
       tab = strchr (help, '\t');
--- gcc/po/exgettext.jj	2020-01-12 11:54:36.784407811 +0100
+++ gcc/po/exgettext	2020-02-17 15:34:40.308915980 +0100
@@ -227,6 +227,7 @@  END {
 	}
     }
     print emsg > posr
+    print "--keyword=__opt_help_text\n--flag=__opt_help_text:1:no-c-format" >> kopt
 }'
 ) || exit
 
@@ -240,7 +241,7 @@  echo "scanning option files..." >&2
     while (getline < file) {
 	if (/^[ \t]*(;|$)/ || !/^[^ \t]/) {
 	    if (field > 2)
-		printf("_(\"%s\")\n", line)
+		printf("__opt_help_text(\"%s\")\n", line)
 	    field = 0
 	} else {
 	    if ((field == 1) && /MissingArgError/) {
@@ -287,7 +288,7 @@  echo "scanning option files..." >&2
 	lineno++;
     }
     if (field > 2)
-	printf("_(\"%s\")\n", line)
+	printf("__opt_help_text(\"%s\")\n", line)
   }') >> $emsg
 
 # Run the xgettext commands, with temporary added as a file to scan.