From: Euler Taveira <euler@eulerto.com>
To: Nathan Bossart <nathandbossart@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Gilles Darold <gilles@darold.net>
Cc: Zsolt Parragi <zsolt.parragi@percona.com>
Cc: japin <japinli@hotmail.com>
Cc: Yuefei Shi <shiyuefei1004@gmail.com>
Cc: songjinzhou <tsinghualucky912@foxmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: liu xiaohui <liuxh.zj.cn@gmail.com>
Cc: Steven Niu <niushiji@gmail.com>
Subject: Re: Pasword expiration warning
Date: Wed, 04 Feb 2026 18:12:07 -0300
Message-ID: <5798afb7-b10c-436f-987e-14fb625df7d0@app.fastmail.com> (raw)
In-Reply-To: <aYN3EybnG9ym-Swh@nathan>
References: <MEAPR01MB3031CF12043573A245D931AAB69EA@MEAPR01MB3031.ausprd01.prod.outlook.com>
<CAN4CZFP4AGeO-AynwE3e62XOKqaYnXtcGT1qfj=6nw2t5FOXwA@mail.gmail.com>
<aXuehKtwtUXWVFYp@nathan>
<197512e0-8116-4776-a600-822d29ee68a6@darold.net>
<aYDZA3r3lG2oKc5D@nathan>
<c933b0f1-ed95-4327-aca6-538acd2c547f@darold.net>
<aYDlAhyYkjaEoEm7@nathan>
<aYEJhk83XAqk76dP@nathan>
<aYIUMbyDWobSi94m@nathan>
<1f4d0b80-3fea-4f4d-8d33-a652ea23e90b@eisentraut.org>
<aYN3EybnG9ym-Swh@nathan>
On Wed, Feb 4, 2026, at 1:42 PM, Nathan Bossart wrote:
> On Wed, Feb 04, 2026 at 03:44:05PM +0100, Peter Eisentraut wrote:
>> On 03.02.26 16:28, Nathan Bossart wrote:
>>> + detail = psprintf(_("The password for role \"%s\" will expire in "
>>> + INT64_FORMAT " day(s), " INT64_FORMAT
>>> + " hour(s), " INT64_FORMAT " minute(s)."),
>>> + role, days, hours, minutes);
>>
>> You cannot use INT64_FORMAT inside translatable messages. But you can use
>> PRId64.
>
> Ah, I didn't know that. Is this documented anywhere? I skimmed through
> our message-writing guidelines [0] but didn't see any mention of this.
>
In the gettext documentation [1]. Maybe we should also add this information to
the referred section.
>> That said, I find writing plurals with "(s)" kind of lame. It's not a good
>> look.
>>
>> It's a bit difficult to do this correctly when you have three separate
>> values in one string. I would consider for example just showing the number
>> of days if the value is larger than one day, number hours if it's larger
>> than one hour, else minutes. I don't think you need minute-precision when
>> the expiration time is several days out.
>
> I think we still have the problem with plurals if we go this route, and
> IIUC there isn't a good way to do something like errmsg_plural() here since
> we are just saving the message for later. I'm skeptical it's worth adding
> new translatable-plural handling functionality for this.
>
That's correct. You should use ngettext(). Using the plural form means better
translation. Looking at some messages in the catalog, the developers tend to
ignore the fact that the sentence has a plural form too. Sometimes it is hard
to write a message if multiple parts of the message have plural form. I
completely understand your resistance.
>> Alternatively, just print the actual expiration timestamp.
>
> That crossed my mind, but I worried about timezone/formatting questions,
> and I haven't found any examples of putting a timestamp in an error message
> like this. Is it acceptable to use pg_strftime() in a translated string?
>
Although we can add the expiration timestamp, I don't think that's a good UI
because (a) there might be timezone difference and (b) you need to do the math
of the remaining time. We can add it but when we are talking about time until a
certain event, we are expecting a countdown format. If the user decides to
change the password because of this message, we don't need inform the exact
remaining time. I agree with Peter that just the largest unit is sufficient for
the user to take some action. Let's say the remaining time is 1 day and 14
hours. If I just inform the 1 day, I know that I have at least 24 hours to
change it and it is sufficient to postpone that action to tomorrow because your
work day ends in a few minutes.
[1] https://www.gnu.org/software/gettext/manual/html_node/No-string-concatenation.html#The-_003cinttypes...
[2] https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
--
Euler Taveira
EDB https://www.enterprisedb.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: euler@eulerto.com, nathandbossart@gmail.com, peter@eisentraut.org, gilles@darold.net, zsolt.parragi@percona.com, japinli@hotmail.com, shiyuefei1004@gmail.com, tsinghualucky912@foxmail.com, andrew@dunslane.net, tgl@sss.pgh.pa.us, liuxh.zj.cn@gmail.com, niushiji@gmail.com
Subject: Re: Pasword expiration warning
In-Reply-To: <5798afb7-b10c-436f-987e-14fb625df7d0@app.fastmail.com>
References: <MEAPR01MB3031CF12043573A245D931AAB69EA@MEAPR01MB3031.ausprd01.prod.outlook.com> <CAN4CZFP4AGeO-AynwE3e62XOKqaYnXtcGT1qfj=6nw2t5FOXwA@mail.gmail.com> <aXuehKtwtUXWVFYp@nathan> <197512e0-8116-4776-a600-822d29ee68a6@darold.net> <aYDZA3r3lG2oKc5D@nathan> <c933b0f1-ed95-4327-aca6-538acd2c547f@darold.net> <aYDlAhyYkjaEoEm7@nathan> <aYEJhk83XAqk76dP@nathan> <aYIUMbyDWobSi94m@nathan> <1f4d0b80-3fea-4f4d-8d33-a652ea23e90b@eisentraut.org> <aYN3EybnG9ym-Swh@nathan> <5798afb7-b10c-436f-987e-14fb625df7d0@app.fastmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox