]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
po: skip automated fuzzy translations when generating new po files
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 18 May 2026 11:56:39 +0000 (12:56 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 20 May 2026 12:28:49 +0000 (14:28 +0200)
The fuzzy translations are always wrong, but meson's integration does
not allow skipping them. Add a tiny wrapper for 'msgmerge' to
workaround the issue and skip them when running ninja systemd-update-po

po/meson.build
tools/msgmerge-no-fuzzy.py [new file with mode: 0755]

index 0a140b40b50cba43fee87974b62c95ebf7c40813..682c16ab1182e67643db8ca3a0d2eb6749687b78 100644 (file)
@@ -3,6 +3,12 @@
 want_translations = get_option('translations')
 
 if want_translations
+        # The msgmerge invocation hidden behind i18n.gettext()'s update-po target inserts auto-guessed
+        # "fuzzy" translations for new strings, which are almost always wrong, use a wrapper to skip it.
+        meson.override_find_program(
+                'msgmerge',
+                find_program('../tools/msgmerge-no-fuzzy.py'))
+
         i18n = import('i18n')
         i18n.gettext(meson.project_name(),
                      preset : 'glib',
diff --git a/tools/msgmerge-no-fuzzy.py b/tools/msgmerge-no-fuzzy.py
new file mode 100755 (executable)
index 0000000..a9171db
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+"""
+Fuzzy translations are always bogus, but the meson integration doesn't allow overriding. With this wrapper
+we can skip them.
+"""
+
+import os
+import shutil
+import sys
+
+msgmerge = shutil.which('msgmerge')
+if msgmerge is None:
+    sys.exit('msgmerge-no-fuzzy: msgmerge not found in PATH')
+
+os.execv(msgmerge, [msgmerge, '--no-fuzzy-matching', *sys.argv[1:]])