Generate translator comments for GUC parameter descriptions
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 28 Nov 2025 15:00:57 +0000 (16:00 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 28 Nov 2025 15:01:59 +0000 (16:01 +0100)
Automatically generate comments like

    /* translator: GUC parameter "client_min_messages" short description */

in the generated guc_tables.inc.c.

This provides translators more context.

Reviewed-by: Pavlo Golub <pavlo.golub@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Stéphane Schildknecht <sas.postgresql@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/1a89b3f0-e588-41ef-b712-aba766143cad%40eisentraut.org

src/backend/utils/misc/gen_guc_tables.pl

index 562819b783268c12d4bf590bdb5de8c56fbba30f..64932e102ba3a1b2571d51721f4f8909774950a5 100644 (file)
@@ -110,11 +110,20 @@ sub print_table
        printf $ofh "\t\t.name = %s,\n", dquote($entry->{name});
        printf $ofh "\t\t.context = %s,\n", $entry->{context};
        printf $ofh "\t\t.group = %s,\n", $entry->{group};
+       printf $ofh
+         "\t\t/* translator: GUC parameter \"%s\" short description */\n",
+         $entry->{name};
        printf $ofh "\t\t.short_desc = gettext_noop(%s),\n",
          dquote($entry->{short_desc});
-       printf $ofh "\t\t.long_desc = gettext_noop(%s),\n",
-         dquote($entry->{long_desc})
-         if $entry->{long_desc};
+
+       if ($entry->{long_desc})
+       {
+           printf $ofh
+             "\t\t/* translator: GUC parameter \"%s\" long description */\n",
+             $entry->{name};
+           printf $ofh "\t\t.long_desc = gettext_noop(%s),\n",
+             dquote($entry->{long_desc});
+       }
        printf $ofh "\t\t.flags = %s,\n", $entry->{flags} if $entry->{flags};
        printf $ofh "\t\t.vartype = %s,\n", ('PGC_' . uc($entry->{type}));
        printf $ofh "\t\t._%s = {\n", $entry->{type};