Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vLtOD-00DdZK-2P for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Nov 2025 01:23:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vLtOB-00GdAJ-23 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Nov 2025 01:23:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vLtOB-00GdA5-10 for pgsql-hackers@lists.postgresql.org; Thu, 20 Nov 2025 01:23:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vLtO9-000SSq-0L for pgsql-hackers@lists.postgresql.org; Thu, 20 Nov 2025 01:23:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5AK1N14m1774836; Wed, 19 Nov 2025 20:23:01 -0500 From: Tom Lane To: Thomas Munro cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Peter Eisentraut , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: PRI?64 vs Visual Studio (2022) In-reply-to: <1689927.1763591033@sss.pgh.pa.us> References: <1462038.1763567038@sss.pgh.pa.us> <202511191705.fxfewzkxoj27@alvherre.pgsql> <1654112.1763587807@sss.pgh.pa.us> <1689927.1763591033@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 19 Nov 2025 17:23:53 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1774800.1763601760.0@sss.pgh.pa.us> Date: Wed, 19 Nov 2025 20:23:01 -0500 Message-ID: <1774835.1763601781@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1774800.1763601760.1@sss.pgh.pa.us> I wrote: > The main thing that's likely wrong here is that I just manually > shoved a new entry into src/backend/po/es.po. I suspect that > the .po-extraction machinery would fail to pick up that string > because it's in src/test/regress/regress.c. We could hack it > to do that, or we could put the test function into some backend > file. I don't have much sense of which would be cleaner. Oh, better idea about that: let's make regress.so have its own translation domain. This allows testing the TEXTDOMAIN mechanism as well as the basics, and it keeps the patch pretty self-contained. I was amused to see that "make update-po" was able to fill in translations for all of the pre-existing ereport's in regress.c. I guess they all had duplicates somewhere else? But I take no credit or blame for any of those translations. The other loose ends remain. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="v2-0001-Simple-test-of-NLS-translation.patch"; charset="UTF-8" Content-ID: <1774800.1763601760.2@sss.pgh.pa.us> Content-Description: v2-0001-Simple-test-of-NLS-translation.patch Content-Transfer-Encoding: quoted-printable =46rom 4cc78e9deea5cd69d711bdf15d20d9b8e80d363f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 19 Nov 2025 20:16:57 -0500 Subject: [PATCH v2] Simple test of NLS translation. This is just intended to verify minimal functionality of the NLS message-translation system, and in particular to check that the PRI* macros work. --- src/test/regress/expected/nls.out | 18 +++++++++ src/test/regress/expected/nls_1.out | 17 +++++++++ src/test/regress/meson.build | 2 + src/test/regress/nls.mk | 5 +++ src/test/regress/parallel_schedule | 2 +- src/test/regress/po/LINGUAS | 1 + src/test/regress/po/es.po | 59 +++++++++++++++++++++++++++++ src/test/regress/po/meson.build | 3 ++ src/test/regress/regress.c | 32 ++++++++++++++++ src/test/regress/sql/nls.sql | 16 ++++++++ 10 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 src/test/regress/expected/nls.out create mode 100644 src/test/regress/expected/nls_1.out create mode 100644 src/test/regress/nls.mk create mode 100644 src/test/regress/po/LINGUAS create mode 100644 src/test/regress/po/es.po create mode 100644 src/test/regress/po/meson.build create mode 100644 src/test/regress/sql/nls.sql diff --git a/src/test/regress/expected/nls.out b/src/test/regress/expected= /nls.out new file mode 100644 index 00000000000..d16c29741db --- /dev/null +++ b/src/test/regress/expected/nls.out @@ -0,0 +1,18 @@ +-- directory paths and dlsuffix are passed to us in environment variables +\getenv libdir PG_LIBDIR +\getenv dlsuffix PG_DLSUFFIX +\set regresslib :libdir '/regress' :dlsuffix +CREATE FUNCTION test_translation() + RETURNS void + AS :'regresslib' + LANGUAGE C; +SET lc_messages =3D 'es_ES'; +SELECT test_translation(); +NOTICE: traducido PRId64 =3D 4242 +NOTICE: traducido PRId32 =3D -1234 + test_translation = +------------------ + = +(1 row) + +RESET lc_messages; diff --git a/src/test/regress/expected/nls_1.out b/src/test/regress/expect= ed/nls_1.out new file mode 100644 index 00000000000..4b707e9dad4 --- /dev/null +++ b/src/test/regress/expected/nls_1.out @@ -0,0 +1,17 @@ +-- directory paths and dlsuffix are passed to us in environment variables +\getenv libdir PG_LIBDIR +\getenv dlsuffix PG_DLSUFFIX +\set regresslib :libdir '/regress' :dlsuffix +CREATE FUNCTION test_translation() + RETURNS void + AS :'regresslib' + LANGUAGE C; +SET lc_messages =3D 'es_ES'; +SELECT test_translation(); +NOTICE: NLS is not enabled + test_translation = +------------------ + = +(1 row) + +RESET lc_messages; diff --git a/src/test/regress/meson.build b/src/test/regress/meson.build index 1da9e9462a9..4001a81ffe5 100644 --- a/src/test/regress/meson.build +++ b/src/test/regress/meson.build @@ -57,3 +57,5 @@ tests +=3D { 'dbname': 'regression', }, } + +subdir('po', if_found: libintl) diff --git a/src/test/regress/nls.mk b/src/test/regress/nls.mk new file mode 100644 index 00000000000..43227c64f09 --- /dev/null +++ b/src/test/regress/nls.mk @@ -0,0 +1,5 @@ +# src/test/regress/nls.mk +CATALOG_NAME =3D regress +GETTEXT_FILES =3D regress.c +GETTEXT_TRIGGERS =3D $(BACKEND_COMMON_GETTEXT_TRIGGERS) +GETTEXT_FLAGS =3D $(BACKEND_COMMON_GETTEXT_FLAGS) diff --git a/src/test/regress/parallel_schedule b/src/test/regress/paralle= l_schedule index f56482fb9f1..66ce1b7d9cd 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -76,7 +76,7 @@ test: brin_bloom brin_multi # ---------- # Another group of parallel tests # ---------- -test: create_table_like alter_generic alter_operator misc async dbsize me= rge misc_functions sysviews tsrf tid tidscan tidrangescan collate.utf8 col= late.icu.utf8 incremental_sort create_role without_overlaps generated_virt= ual +test: create_table_like alter_generic alter_operator misc async dbsize me= rge misc_functions nls sysviews tsrf tid tidscan tidrangescan collate.utf8= collate.icu.utf8 incremental_sort create_role without_overlaps generated_= virtual = # collate.linux.utf8 and collate.icu.utf8 tests cannot be run in parallel= with each other # psql depends on create_am diff --git a/src/test/regress/po/LINGUAS b/src/test/regress/po/LINGUAS new file mode 100644 index 00000000000..8357fcaaed4 --- /dev/null +++ b/src/test/regress/po/LINGUAS @@ -0,0 +1 @@ +es diff --git a/src/test/regress/po/es.po b/src/test/regress/po/es.po new file mode 100644 index 00000000000..3049b73f9f9 --- /dev/null +++ b/src/test/regress/po/es.po @@ -0,0 +1,59 @@ +# Spanish message translation file for regress test library +# +# Copyright (C) 2025 PostgreSQL Global Development Group +# This file is distributed under the same license as the regress (Postgre= SQL) package. +# +# Tom Lane , 2025. +# +msgid "" +msgstr "" +"Project-Id-Version: regress (PostgreSQL) 19\n" +"Report-Msgid-Bugs-To: pgsql-bugs@lists.postgresql.org\n" +"POT-Creation-Date: 2025-11-19 19:01-0500\n" +"PO-Revision-Date: 2025-11-19 19:01-0500\n" +"Last-Translator: Tom Lane \n" +"Language-Team: PgSQL-es-Ayuda \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=3DUTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: regress.c:200 +#, c-format +msgid "invalid input syntax for type %s: \"%s\"" +msgstr "la sintaxis de entrada no es v=C3=A1lida para tipo %s: =C2=AB%s=C2= =BB" + +#: regress.c:907 +#, c-format +msgid "invalid source encoding name \"%s\"" +msgstr "la codificaci=C3=B3n de origen =C2=AB%s=C2=BB no es v=C3=A1lida" + +#: regress.c:912 +#, c-format +msgid "invalid destination encoding name \"%s\"" +msgstr "la codificaci=C3=B3n de destino =C2=AB%s=C2=BB no es v=C3=A1lida" + +#: regress.c:957 +#, c-format +msgid "default conversion function for encoding \"%s\" to \"%s\" does not= exist" +msgstr "no existe el procedimiento por omisi=C3=B3n de conversi=C3=B3n de= sde la codificaci=C3=B3n =C2=AB%s=C2=BB a =C2=AB%s=C2=BB" + +#: regress.c:964 +#, c-format +msgid "out of memory" +msgstr "memoria agotada" + +#: regress.c:965 +#, c-format +msgid "String of %d bytes is too long for encoding conversion." +msgstr "La cadena de %d bytes es demasiado larga para la recodificaci=C3=B3= n." + +#: regress.c:1054 +#, c-format +msgid "translated PRId64 =3D %" +msgstr "traducido PRId64 =3D %" + +#: regress.c:1056 +#, c-format +msgid "translated PRId32 =3D %" +msgstr "traducido PRId32 =3D %" diff --git a/src/test/regress/po/meson.build b/src/test/regress/po/meson.b= uild new file mode 100644 index 00000000000..e9bd964aa7f --- /dev/null +++ b/src/test/regress/po/meson.build @@ -0,0 +1,3 @@ +# Copyright (c) 2022-2025, PostgreSQL Global Development Group + +nls_targets +=3D [i18n.gettext('regress-' + pg_version_major.to_string())= ] diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index a2db6080876..4a584ca88ae 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -46,6 +46,10 @@ #include "utils/rel.h" #include "utils/typcache.h" = +/* define our text domain for translations */ +#undef TEXTDOMAIN +#define TEXTDOMAIN PG_TEXTDOMAIN("regress") + #define EXPECT_TRUE(expr) \ do { \ if (!(expr)) \ @@ -1028,3 +1032,31 @@ test_relpath(PG_FUNCTION_ARGS) = PG_RETURN_VOID(); } + +/* + * Simple test to verify NLS support, particularly that the PRI* macros w= ork. + */ +PG_FUNCTION_INFO_V1(test_translation); +Datum +test_translation(PG_FUNCTION_ARGS) +{ +#ifdef ENABLE_NLS + /* This would be better done in _PG_init(), if this module had one */ + static bool inited =3D false; + + if (!inited) + { + pg_bindtextdomain(TEXTDOMAIN); + inited =3D true; + } + + ereport(NOTICE, + errmsg("translated PRId64 =3D %" PRId64, (int64) 4242)); + ereport(NOTICE, + errmsg("translated PRId32 =3D %" PRId32, (int32) -1234)); +#else + elog(NOTICE, "NLS is not enabled"); +#endif + + PG_RETURN_VOID(); +} diff --git a/src/test/regress/sql/nls.sql b/src/test/regress/sql/nls.sql new file mode 100644 index 00000000000..53b4add86eb --- /dev/null +++ b/src/test/regress/sql/nls.sql @@ -0,0 +1,16 @@ +-- directory paths and dlsuffix are passed to us in environment variables +\getenv libdir PG_LIBDIR +\getenv dlsuffix PG_DLSUFFIX + +\set regresslib :libdir '/regress' :dlsuffix + +CREATE FUNCTION test_translation() + RETURNS void + AS :'regresslib' + LANGUAGE C; + +SET lc_messages =3D 'es_ES'; + +SELECT test_translation(); + +RESET lc_messages; -- = 2.43.7 ------- =_aaaaaaaaaa0--