Blame common.mk

rpm-build 393af8
xmldir = $(datadir)/xml/iso-codes
rpm-build 393af8
nodist_xml_DATA = $(DOMAIN).xml
rpm-build 393af8
rpm-build 393af8
pofiles = $(wildcard $(srcdir)/*.po)
rpm-build 393af8
mofiles = $(patsubst $(srcdir)/%.po,%.mo, $(pofiles))
rpm-build 393af8
noinst_DATA = $(mofiles) $(xml_DATA:.xml=.pot)
rpm-build 393af8
rpm-build 393af8
localedir = $(datadir)/locale
rpm-build 393af8
rpm-build 393af8
EXTRA_DIST = \
rpm-build 393af8
	$(pofiles)	\
rpm-build 393af8
	$(DOMAIN).pot
rpm-build 393af8
rpm-build 393af8
MOSTLYCLEANFILES = \
rpm-build 393af8
	$(mofiles) \
rpm-build 393af8
	$(DOMAIN).xml
rpm-build 393af8
rpm-build 393af8
# Generic target to create binary .mo files from .po files
rpm-build 393af8
%.mo: %.po
rpm-build 393af8
	$(MSGFMT) $(MSGFMT_FLAGS) -o $@ $<
rpm-build 393af8
rpm-build 393af8
# Generic target to create .pot files from JSON data files
rpm-build 393af8
$(DOMAIN).pot: $(top_srcdir)/bin/pot_from_json.py $(top_srcdir)/data/$(DOMAIN).json $(top_srcdir)/bin/remove-potcdate.sin
rpm-build 393af8
	cp $@ backup.pot
rpm-build 393af8
	python3 $(top_srcdir)/bin/pot_from_json.py $(DOMAIN) $(top_srcdir)/data
rpm-build 393af8
	sed -f $(top_srcdir)/bin/remove-potcdate.sin < $@ > $(DOMAIN).1po
rpm-build 393af8
	sed -f $(top_srcdir)/bin/remove-potcdate.sin < backup.pot > $(DOMAIN).2po
rpm-build 393af8
	if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
rpm-build 393af8
		rm -f $(DOMAIN).1po $(DOMAIN).2po $@ && \
rpm-build 393af8
		mv backup.pot $@; \
rpm-build 393af8
	else \
rpm-build 393af8
		rm -f $(DOMAIN).1po $(DOMAIN).2po backup.pot; \
rpm-build 393af8
	fi
rpm-build 393af8
rpm-build 393af8
# Generic target to create deprecated .xml files from JSON data files
rpm-build 393af8
$(DOMAIN).xml: $(top_srcdir)/bin/xml_from_json.py $(top_srcdir)/data/$(DOMAIN).json
rpm-build 393af8
	python3 $(top_srcdir)/bin/xml_from_json.py $(DOMAIN) $(top_srcdir)/data $@
rpm-build 393af8
rpm-build 393af8
# Used in the domain subdirectories for checking that
rpm-build 393af8
# all .po files contain UTF-8 data
rpm-build 393af8
check-local:
rpm-build 393af8
	python3 $(top_srcdir)/bin/check_valid_utf8.py $(pofiles)
rpm-build 393af8
rpm-build 393af8
# This target merges all po files with the current pot file,
rpm-build 393af8
# removes obsolete msgids and substitutes the Project-Id-Version
rpm-build 393af8
# header with the PROJECT only, removing the VERSION part.
rpm-build 393af8
# This is done to keep the diff between releases small.
rpm-build 393af8
#
rpm-build 393af8
# NOTE:
rpm-build 393af8
# Removing obsolete msgids is not the recommended way to go.
rpm-build 393af8
# However, we've decided that in the specific case of iso-codes
rpm-build 393af8
# the benefit outweights the loss of information. Having only msgids
rpm-build 393af8
# with one (sometimes two or three) words, the fuzzy matching performed
rpm-build 393af8
# with obsolete msgids will not ease the translator's work, but
rpm-build 393af8
# will lead to confusing entries.
rpm-build 393af8
#
rpm-build 393af8
# However, if there is only a small change, we include the fuzzy
rpm-build 393af8
# entry with the previous msgid to hopefully save some work.
rpm-build 393af8
.PHONY: update-po
rpm-build 393af8
update-po:
rpm-build 393af8
	for pofile in $(pofiles); do \
rpm-build 393af8
		$(MSGMERGE) --previous $$pofile $(DOMAIN).pot > tmpfile; \
rpm-build 393af8
		$(MSGATTRIB) --no-obsolete tmpfile > $$pofile; \
rpm-build 393af8
		sed -i -e 's/^\"Project-Id-Version: iso.*/\"Project-Id-Version: $(DOMAIN)\\n\"/' $$pofile; \
rpm-build 393af8
	done
rpm-build 393af8
	rm -f tmpfile
rpm-build 393af8
	if [ -f sr.po ]; then \
rpm-build 393af8
		$(RECODE_SR_LATIN) < sr.po > sr@latin.po; \
rpm-build 393af8
		sed -i -e 's/^\"Language: sr\\n\"/\"Language: sr@latin\\n\"/' sr@latin.po; \
rpm-build 393af8
	fi
rpm-build 393af8
	if [ -f tt@iqtelif.po ]; then \
rpm-build 393af8
		$(MSGFILTER) --keep-header sed -f $(top_srcdir)/bin/recode-tt-cyrillic.sed < tt@iqtelif.po > tt.po; \
rpm-build 393af8
		sed -i -e 's/^\"Language: tt@iqtelif\\n\"/\"Language: tt\\n\"/' tt.po; \
rpm-build 393af8
	fi
rpm-build 393af8
rpm-build 393af8
install-data-hook: $(mofiles)
rpm-build 393af8
	$(mkinstalldirs) $(DESTDIR)$(localedir)
rpm-build 393af8
	catalogs='$(mofiles)'; \
rpm-build 393af8
	for cat in $$catalogs; do \
rpm-build 393af8
		cat=`basename $$cat`; \
rpm-build 393af8
		lang=`echo $$cat | sed 's/\.mo$$//'`; \
rpm-build 393af8
		dir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \
rpm-build 393af8
		$(mkinstalldirs) $$dir; \
rpm-build 393af8
		$(INSTALL_DATA) $$cat $$dir/$(DOMAIN).mo; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_639-2" ]; then (cd $$dir && $(LN_S) $(DOMAIN).mo iso_639.mo); fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_639-3" ]; then (cd $$dir && $(LN_S) $(DOMAIN).mo iso_639_3.mo); fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_639-5" ]; then (cd $$dir && $(LN_S) $(DOMAIN).mo iso_639_5.mo); fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_3166-1" ]; then (cd $$dir && $(LN_S) $(DOMAIN).mo iso_3166.mo); fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_3166-2" ]; then (cd $$dir && $(LN_S) $(DOMAIN).mo iso_3166_2.mo); fi; \
rpm-build 393af8
	done
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_639-2" ]; then (cd $(DESTDIR)$(xmldir) && $(LN_S) $(DOMAIN).xml iso_639.xml); fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_639-3" ]; then (cd $(DESTDIR)$(xmldir) && $(LN_S) $(DOMAIN).xml iso_639_3.xml); fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_639-5" ]; then (cd $(DESTDIR)$(xmldir) && $(LN_S) $(DOMAIN).xml iso_639_5.xml); fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_3166-1" ]; then (cd $(DESTDIR)$(xmldir) && $(LN_S) $(DOMAIN).xml iso_3166.xml); fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_3166-2" ]; then (cd $(DESTDIR)$(xmldir) && $(LN_S) $(DOMAIN).xml iso_3166_2.xml); fi
rpm-build 393af8
rpm-build 393af8
uninstall-hook:
rpm-build 393af8
	catalogs='$(mofiles)'; \
rpm-build 393af8
	for cat in $$catalogs; do \
rpm-build 393af8
		cat=`basename $$cat`; \
rpm-build 393af8
		lang=`echo $$cat | sed 's/\.mo$$//'`; \
rpm-build 393af8
		rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_639-2" ]; then rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/iso_639.mo; fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_639-3" ]; then rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/iso_639_3.mo; fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_639-5" ]; then rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/iso_639_5.mo; fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_3166-1" ]; then rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/iso_3166.mo; fi; \
rpm-build 393af8
		if [ "$(DOMAIN)" = "iso_3166-1" ]; then rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/iso_3166_2.mo; fi; \
rpm-build 393af8
	done
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_639-2" ]; then rm -f $(DESTDIR)$(xmldir)/iso_639.xml; fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_639-3" ]; then rm -f $(DESTDIR)$(xmldir)/iso_639_3.xml; fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_639-5" ]; then rm -f $(DESTDIR)$(xmldir)/iso_639_5.xml; fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_3166-1" ]; then rm -f $(DESTDIR)$(xmldir)/iso_3166.xml; fi
rpm-build 393af8
	if [ "$(DOMAIN)" = "iso_3166-2" ]; then rm -f $(DESTDIR)$(xmldir)/iso_3166_2.xml; fi