]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: po: introduce libvirt translation
authorPavel Hrdina <phrdina@redhat.com>
Mon, 29 Jun 2020 19:55:39 +0000 (21:55 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 3 Aug 2020 07:27:06 +0000 (09:27 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Makefile.am
configure.ac
meson.build
po/Makefile.am [deleted file]
po/meson.build [new file with mode: 0644]

index 4b3abc827282cba4619ecdce7ebc721b095a1a83..fca0c1f5c290c0635b1931967287e91dc5401298 100644 (file)
@@ -20,8 +20,7 @@
 # so force it explicitly
 DISTCHECK_CONFIGURE_FLAGS = --enable-werror
 
-SUBDIRS = . docs \
-  po
+SUBDIRS = . docs
 
 XZ_OPT ?= -v -T0
 export XZ_OPT
index 94e8796af1a00f442daf09c46bd1aaaff7faeca8..2a586f12fe333aee2fbd3c9bd8eeda54089fe22d 100644 (file)
@@ -113,6 +113,5 @@ AC_CONFIG_FILES([\
         libvirt-qemu.pc \
         libvirt-lxc.pc \
         libvirt-admin.pc \
-        libvirt.spec mingw-libvirt.spec \
-        po/Makefile])
+        libvirt.spec mingw-libvirt.spec])
 AC_OUTPUT
index e8d79caf1d7148c7a57757409c265c2a65a7bd36..a1f4435dc3b3495a84adb5620084d93ccc0ebec2 100644 (file)
@@ -2229,6 +2229,8 @@ subdir('tests')
 
 subdir('examples')
 
+subdir('po')
+
 
 # generate meson-config.h file
 configure_file(output: 'meson-config.h', configuration: conf)
diff --git a/po/Makefile.am b/po/Makefile.am
deleted file mode 100644 (file)
index ff73ead..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-DOMAIN = $(PACKAGE_NAME)
-COPYRIGHT_HOLDER = The Libvirt authors
-MSGID_BUGS_ADDRESS = https://libvirt.org/bugs.html
-
-LANGS := $(shell cat $(srcdir)/LINGUAS)
-
-POTFILES_IN = $(srcdir)/POTFILES.in
-POTFILES: $(POTFILES_IN)
-       $(AM_V_GEN) cat $(POTFILES_IN) | \
-               $(SED) 's|[@]SRCDIR[@]||' | \
-               $(SED) 's|[@]BUILDDIR[@]||' > $@
-POTFILE_DEPS = $(shell cat POTFILES)
-POTFILE := $(DOMAIN).pot
-POFILES := $(LANGS:%=%.po)
-GMOFILES := $(LANGS:%=%.gmo)
-
-if HAVE_GNU_GETTEXT_TOOLS
-
-XGETTEXT_ARGS = \
-       --default-domain=$(DOMAIN) \
-       --from-code=utf-8 \
-       --add-comments=TRANSLATORS: \
-        --keyword=_ --keyword=N_ \
-       --copyright-holder='$(COPYRIGHT_HOLDER)' \
-       --package-name="$(PACKAGE_NAME)" \
-       --package-version="$(PACKAGE_VERSION)" \
-       --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
-       --directory="$(top_srcdir)" \
-       --directory="$(top_builddir)" \
-       --sort-output \
-       $(NULL)
-
-SED_PO_FIXUP_ARGS = \
-       -e "s|text/plain; charset=CHARSET|text/plain; charset=UTF-8|g" \
-       -e "s|SOME DESCRIPTIVE TITLE|Libvirt package strings|g" \
-       -e "s|Copyright (C) YEAR|Copyright (C) $$(date +'%Y')|" \
-       $(NULL)
-
-update-gmo: $(GMOFILES)
-
-# The results of this target should not be committed to Git. The Weblate
-# service is responsible for updating .po files when the .pot is changed.
-update-po: $(POTFILE)
-       cd $(srcdir) && \
-       for lang in $(LANGS); do \
-         echo "Minimizing $$lang content" && \
-         $(MSGMERGE) --no-location --no-fuzzy-matching --sort-output \
-           $$lang.po $(POTFILE) | \
-         $(SED) $(SED_PO_FIXUP_ARGS) > $$lang.po-t && \
-         mv $$lang.po-t $$lang.po ; \
-       done
-
-$(POTFILE): POTFILES
-       $(XGETTEXT) -o $@-t $(XGETTEXT_ARGS) \
-         --files-from=$(abs_builddir)/POTFILES
-       $(SED) $(SED_PO_FIXUP_ARGS) < $@-t > $(srcdir)/$@
-       rm -f $@-t
-
-%.gmo: %.po
-       rm -f $@ $@-t
-       $(MSGFMT) -c -o $@-t $<
-       mv $@-t $@
-
-.PHONY: $(POTFILE)
-
-endif HAVE_GNU_GETTEXT_TOOLS
-
-if ENABLE_NLS
-
-# Cannot use 'localedir' since this conflicts with autoconf.
-langinstdir = $(datadir)/locale
-
-install-data-hook: $(GMOFILES)
-       mkdir -p $(DESTDIR)$(langinstdir)
-       for lang in $(LANGS); do \
-         d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
-         mkdir -p $$d; \
-         install -m 0644 $$lang.gmo $$d/$(DOMAIN).mo; \
-       done
-
-uninstall-hook:
-       for lang in $(LANGS); do \
-         d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
-         rm -f $$d/$(DOMAIN).mo; \
-       done
-
-endif ENABLE_NLS
diff --git a/po/meson.build b/po/meson.build
new file mode 100644 (file)
index 0000000..f967740
--- /dev/null
@@ -0,0 +1,35 @@
+i18n = import('i18n')
+
+potfiles_conf = configuration_data()
+potfiles_conf.set('SRCDIR', '')
+potfiles_conf.set('BUILDDIR', '')
+
+potfiles = configure_file(
+  input: 'POTFILES.in',
+  output: 'POTFILES',
+  configuration: potfiles_conf,
+)
+
+i18n.gettext(
+  meson.project_name(),
+  args: [
+    '--add-comments=TRANSLATORS:',
+    '--directory=@0@'.format(meson.source_root()),
+    '--directory=@0@'.format(meson.build_root()),
+    '--files-from=@0@'.format(meson.current_build_dir() / 'POTFILES'),
+    '--msgid-bugs-address=https://libvirt.org/bugs.html',
+    '--package-version=@0@'.format(meson.project_version()),
+    '--sort-output',
+  ],
+  preset: 'glib',
+)
+
+potfiles_dep = [
+  access_gen_sources,
+  admin_client_generated,
+  admin_driver_generated,
+  remote_driver_generated,
+  remote_daemon_generated,
+]
+
+alias_target('libvirt-pot-dep', potfiles_dep)