Makefile.am 2.5 KB
Newer Older
1 2 3 4
DOMAIN = $(PACKAGE_NAME)
COPYRIGHT_HOLDER = The Libvirt authors
MSGID_BUGS_ADDRESS = https://libvirt.org/bugs.html

5
LANGS := $(shell cat $(srcdir)/LINGUAS)
6

7 8 9 10 11 12
POTFILES_IN = $(srcdir)/POTFILES.in
POTFILES: $(POTFILES_IN)
	$(AM_V_GEN) cat $(POTFILES_IN) | \
		$(SED) 's|[@]SRCDIR[@]|$(top_srcdir)|' | \
		$(SED) 's|[@]BUILDDIR[@]|$(top_builddir)|' > $@
POTFILE_DEPS = $(shell cat POTFILES)
13 14 15
POTFILE := $(DOMAIN).pot
POFILES := $(LANGS:%=%.po)
GMOFILES := $(LANGS:%=%.gmo)
16

17
CLEANFILES = $(GMOFILES) POTFILES
18

19
EXTRA_DIST = \
20
	LINGUAS \
21
	$(POTFILES_IN) \
22
	$(POFILES)
23 24 25 26 27 28 29 30 31 32 33 34

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)" \
35
	--sort-output \
36 37 38
	$(NULL)

SED_PO_FIXUP_ARGS = \
39 40 41 42
	-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)
43 44 45

update-gmo: $(GMOFILES)

46
update-po: $(POTFILE)
47 48 49 50
	for lang in $(LANGS); do \
	  echo "Minimizing $$lang content" && \
	  $(MSGMERGE) --no-location --no-fuzzy-matching --sort-output \
	    $$lang.po $(POTFILE) | \
51
	  $(SED) $(SED_PO_FIXUP_ARGS) > $(srcdir)/$$lang.po-t && \
52
	  mv $$lang.po-t $$lang.po
53 54
	done

55
push-pot: $(POTFILE)
56 57 58 59 60
	zanata push \
		--project-config $(srcdir)/zanata.xml \
		--push-type=source \
		--transdir $(builddir) \
		--srcdir $(srcdir)
61 62

pull-po: $(POTFILE)
63 64 65 66 67
	zanata pull \
		--project-config $(srcdir)/zanata.xml \
		--create-skeletons \
		--transdir $(builddir) \
		--srcdir $(srcdir)
68
	$(MAKE) update-po
69 70
	$(MAKE) update-gmo

71
$(POTFILE): POTFILES
72
	$(XGETTEXT) -o $@-t $(XGETTEXT_ARGS) \
73
	  --files-from=$(abs_builddir)/POTFILES
74
	$(SED) $(SED_PO_FIXUP_ARGS) < $@-t > $(srcdir)/$@
75 76
	rm -f $@-t

77
%.gmo: %.po
78 79 80
	rm -f $@ $@-t
	$(MSGFMT) -c -o $@-t $<
	mv $@-t $@
81

82
.PHONY: $(POTFILE)
83 84 85

endif HAVE_GNU_GETTEXT_TOOLS

86 87
if ENABLE_NLS

88 89 90 91 92 93 94 95
# 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; \
96
	  install -m 0644 $$lang.gmo $$d/$(DOMAIN).mo; \
97 98 99 100 101 102 103
	done

uninstall-hook:
	for lang in $(LANGS); do \
	  d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
	  rm -f $$d/$(DOMAIN).mo; \
	done
104 105

endif ENABLE_NLS