splitting pg_resetwal output strings

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: splitting pg_resetwal output strings
Date: 2026-01-31 09:41:06
Message-ID: 202601310924.yoik5n3blgt4@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

For a long time I've been annoyed that certain tools such as (but not
only) pg_resetwal have translatable strings full of whitespace that
translators have to be careful about so that things look nice.
For Spanish I have made the lines a bit wider so that everything fits,
which means that every time someone adds a new line that's not yet
translated, the output looks bad; and if I want to add one more space
to align a new longer string, then I have to edit every single one of
them. This is horrible.

Here's a proposal. The idea is to have a separate file (entries.h right
now but proposal for better names are welcome) which lists those
strings, together with the printf specifiers needed to actually print
them. This way, we can measure the length of each exactly as they
translate before printing anything, and then line up everything to the
same output length.

One curious thing of note is that I had to add an internal_wcswidth()
function, to avoid having to link libpq just to be able to do
pg_wcswidth().

This is not complete. It modifies PrintControlValues(), which is easy
because I just print each item in the entries.h file in the same order
they appear there. But for PrintNewControlValues() I'll need to add a
symbolic identifier to each string, that the code can use to scan the
array and print just those elements. I'll do that if there are no
objections to this idea here. Also, pg_controldata could probably
something very similar or maybe the same entries.h file.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"If you want to have good ideas, you must have many ideas. Most of them
will be wrong, and what you have to learn is which ones to throw away."
(Linus Pauling)

Attachment Content-Type Size
0001-Split-out-entry-names-in-pg_resetwal.patch text/x-diff 10.7 KB

Browse pgsql-hackers by date

  From Date Subject
Previous Message Ashutosh Bapat 2026-01-31 08:59:45 Re: Improvements and refactoring in shmem.c