{ echo 'found diagnostic without %' 1>&2; \
exit 1; } || :
+sc_require_permutable_format_in_translation:
+ @prohibit='\<N?_ *\("[^"]*%[^%$$ ]*[a-zA-Z][^"]*"' \
+ halt='non-permutable format string(s)' \
+ $(_sc_search_regexp)
+
# The strings "" and "%s" should never be marked for translation.
# Files under tests/ and examples/ should not be translated.
sc_prohibit_useless_translation:
]
alias_target('libvirt-pot-dep', potfiles_dep)
+
+run_target(
+ 'libvirt-pot-check',
+ command: [
+ '@0@/scripts/check-pot.py'.format(meson.project_source_root()),
+ '@0@/po/libvirt.pot'.format(meson.project_source_root())
+ ],
+)
--- /dev/null
+#!/usr/bin/env python3
+
+import sys
+import re
+
+if len(sys.argv) != 2:
+ print(f"usage: {sys.argv[0]} POTFILE", file=sys.stderr)
+ sys.exit(1)
+
+potfile = sys.argv[1]
+
+failed = 0
+
+
+def print_msg(files, msgs):
+ if len(msgs) == 0:
+ return
+
+ print("\n".join(files))
+
+ for m in msgs:
+ print(f" {m}")
+
+ global failed
+ failed += 1
+
+
+with open(potfile, "r") as pot:
+ files = []
+ msgs = []
+ cFormat = False
+
+ for line in pot:
+ if not line or line.startswith("msgstr "):
+ print_msg(files, msgs)
+ files = []
+ msgs = []
+ cFormat = False
+ continue
+
+ if line.startswith("#: "):
+ files.extend(line[3:].split())
+ continue
+
+ if line.startswith("#,"):
+ cFormat = " c-format" in line
+ continue
+
+ m = re.search(r'^(msgid )?"(.*%[^%$ ]*[a-zA-Z].*)"', line)
+ if cFormat and m is not None:
+ msgs.append(m.group(2))
+
+if failed:
+ print(f"Found {failed} messages without permutable format strings!",
+ file=sys.stderr)
+ sys.exit(1)