From 35ad5e85dd149c7b651b8f7d4dc5fa5eaee9fb23 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 8 Mar 2023 10:58:23 +0100 Subject: [PATCH] build: Add checks for permutable format strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since all messages marked for translation contain permutable format strings, we can add checks for enforcing them. The syntax check does not catch all cases as it only checks format strings between _(" and the first ". In other words messages where \" appears before the first format string or multi-line messages where the first format strings is not in the first line will not be checked. On the other hand, it's run automatically by "meson test". check-pot.py python script will detect all incorrect format strings, but it's not as easy to use as it requires libvirt.pot to be regenerated and this does not happen during a standard build. The following steps are needed to check messages with check-pot.py: meson compile libvirt-pot-dep meson compile libvirt-pot meson compile libvirt-pot-check Don't forget to revert changes to libvirt.pot if you run these commands locally as we don't want each patch series to update libvirt.pot. Shell scripts (tools/libvirt-guests.sh.in is the only one currently) need to be exempt from this check as shell's printf function does not understand the permutable format strings. Signed-off-by: Jiri Denemark Reviewed-by: Daniel P. Berrangé --- build-aux/syntax-check.mk | 5 ++++ po/meson.build | 8 ++++++ scripts/check-pot.py | 56 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100755 scripts/check-pot.py diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 21f6b311ce..5829dc9011 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -455,6 +455,11 @@ sc_prohibit_diagnostic_without_format: { echo 'found diagnostic without %' 1>&2; \ exit 1; } || : +sc_require_permutable_format_in_translation: + @prohibit='\