Re: Pasword expiration warning - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Pasword expiration warning
Date
Msg-id aYN3EybnG9ym-Swh@nathan
Whole thread Raw
In response to Re: Pasword expiration warning  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Pasword expiration warning
Re: Pasword expiration warning
List pgsql-hackers
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.

> Using the type TimestampTz for what are essentially interval/duration
> quantities is a bit weird and confusing.  So maybe another placeholder would
> be more appropriate.

Sure.

> 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.

> 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?

[0] https://www.postgresql.org/docs/devel/nls-programmer.html#NLS-GUIDELINES

-- 
nathan



pgsql-hackers by date:

Previous
From: Sami Imseih
Date:
Subject: Re: Flush some statistics within running transactions
Next
From: Nathan Bossart
Date:
Subject: Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects