2 # Copyright (C) 2009-2020 Red Hat Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 DOMAIN = $(PACKAGE_NAME)
19 COPYRIGHT_HOLDER = Red Hat Inc.
20 MSGID_BUGS_ADDRESS = https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
23 # Don't use LINGUAS (uppercase) as Gentoo defines it (RHBZ#804464).
24 linguas := $(shell cat $(srcdir)/LINGUAS)
26 POTFILES := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES)
27 POTFILES_ML := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES-ml)
28 POFILES := $(linguas:%=%.po)
29 GMOFILES := $(linguas:%=%.gmo)
33 POTFILES POTFILES-ml \
43 --default-domain=$(DOMAIN) \
45 --add-comments=TRANSLATORS: \
46 --keyword=_ --keyword=N_ --keyword=__ --keyword=__x \
47 --flag=error:3:c-format \
48 --flag=error_at_line:5:c-format \
49 --flag=asprintf:2:c-format \
50 --flag=vasprintf:2:c-format \
51 --flag=xasprintf:1:c-format \
52 --copyright-holder='$(COPYRIGHT_HOLDER)' \
53 --package-name="$(PACKAGE_NAME)" \
54 --package-version="$(PACKAGE_VERSION)" \
55 --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
56 --directory=$(top_srcdir)
58 # For explanation, see
59 # http://mingw-users.1079350.n2.nabble.com/Getting-rid-of-xgettext-s-quot-CHARSET-quot-warning-td5620533.html
61 $(SED) -i 's|text/plain; charset=CHARSET|text/plain; charset=utf-8|g'
63 $(DOMAIN).pot: Makefile POTFILES $(POTFILES) POTFILES-ml $(POTFILES_ML)
67 cd $(top_srcdir) && $(OCAML_GETTEXT) --action extract --extract-pot $(abs_srcdir)/$@-t $(shell cat $(abs_srcdir)/POTFILES-ml)
71 $(XGETTEXT) -j -o $@-t $(XGETTEXT_ARGS) \
72 --files-from=$(abs_srcdir)/POTFILES
78 $(MSGFMT) -c -o $@-t $(srcdir)/$<
82 # Cannot use 'localedir' since this conflicts with autoconf.
83 langinstdir = $(datadir)/locale
85 install-data-hook: $(GMOFILES)
86 mkdir -p $(DESTDIR)$(langinstdir)
87 for lang in $(linguas); do \
88 d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
90 install -m 0644 $$lang.gmo $$d/$(DOMAIN).mo; \
93 .PRECIOUS: $(DOMAIN).pot $(POFILES)