summaryrefslogtreecommitdiff
path: root/po/Makefile.am
blob: d757b114473ddbf676bd5143f55037f9f1e78e79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##  Makefile.am -- an automake template for Makefile.in file
##  Copyright (C) 2009 Chris Bagwell and Sane Developers.
##
##  This file is part of the "Sane" build infra-structure.  See
##  included LICENSE file for license information.

# See po/README for documentation.

MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
MSGMERGE = @MSGMERGE@ -w75

GETTEXT_PACKAGE = @PACKAGE@

TMP_FILE_DIR = .tmp

PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; else echo ""; fi)
SRC_FILES=$(shell if test -r $(srcdir)/POTFILES; then grep -v "^\#" $(srcdir)/POTFILES; else echo ""; fi)

PO_FILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
MO_FILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.mo "; done)

EXTRA_DIST = README LINGUAS POTFILES
EXTRA_DIST += $(PO_FILES)


if ENABLE_TRANSLATIONS
EXTRA_DIST += $(GETTEXT_PACKAGE).pot
INSTALL_TRANSLATIONS = install-translations
UNINSTALL_TRANSLATIONS = uninstall-translations
ALL = all-mos
else
INSTALL_TRANSLATIONS = 
UNINSTALL_TRANSLATIONS = 
ALL = 
endif

all: $(ALL)

all-mos: $(MO_FILES)

.po.mo:
	@echo "generating $@ from $^"
	@$(MSGFMT) -o $@ $^

install-translations:
	@for lang in $(PO_LINGUAS) ; do \
	  dir=$(localedir)/$${lang}/LC_MESSAGES ; \
	  echo "installing sane-backends $${lang}.mo to $${dir}/$(GETTEXT_PACKAGE).mo..." ; \
	 $(mkinstalldirs) $(DESTDIR)$${dir} && \
	 $(INSTALL_DATA) $${lang}.mo $(DESTDIR)$${dir}/$(GETTEXT_PACKAGE).mo ; \
	 done

install-data-local: $(INSTALL_TRANSLATIONS)

uninstall-translations:
	@for lang in $(PO_LINGUAS) ; do \
	   dir=$(localedir)/$${lang}/LC_MESSAGES ; \
	   echo removing $${dir}/$(GETTEXT_PACKAGE).mo ; \
	   rm -f $(DESTDIR)$${dir}/$(GETTEXT_PACKAGE).mo ; \
	 done

uninstall-local: $(UNINSTALL_TRANSLATIONS)

clean-local:
	rm -f *.mo
	rm -f *.old
	rm -f *.pot

$(GETTEXT_PACKAGE).pot: $(SRC_FILES)
	@echo "creating $@ from $^"
	@$(XGETTEXT) -d$(GETTEXT_PACKAGE) -kSANE_I18N --flag=SANE_I18N:1:no-c-format -f $(srcdir)/POTFILES -D$(srcdir)
	@mv $(GETTEXT_PACKAGE).po $(GETTEXT_PACKAGE).pot

update: $(GETTEXT_PACKAGE).pot
	@for lang in $(PO_LINGUAS) ; do \
	   pofile=$${lang}.po ; \
	   if test ! -f $${pofile} ; then \
	     echo "creating $${pofile}" ; \
	     cp template.po $${pofile} ; \
	   fi ; \
	   echo "updating $${pofile}" ; \
	   cp $${pofile} $${pofile}.old  ; \
	   $(MSGMERGE) $${pofile}.old $< -o $${pofile} ; \
	   rm -f $${pofile}.old template.po ; \
	 done