Subversion Repositories LCARS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
38 PointedEar 1
# Makefile for various po files.
2
 
3
srcdir = .
4
libdir = ..
5
 
6
#CATALOGS = $(addsuffix .po, LINGUAS)
7
CATALOGS = $(LINGUAS)
8
MO_FILES = $(addsuffix .mo, $(LINGUAS))
9
 
10
MSGMERGE = msgmerge
11
MSGFMT   = msgfmt
12
XGETTEXT = xgettext
13
CATOBJEXT = .po
14
 
15
include PACKAGE
16
 
17
TD = $(strip $(TEXTDOMAIN))
18
 
19
default: help
20
 
21
all: $(TD).pot update-po update-mo install
22
 
23
help:
24
	@echo "Available targets:"
25
	@echo "  pot                       - remake master catalog"
26
	@echo "  update-po                 - merge po files"
27
	@echo "  update-mo                 - regenerate mo files"
28
	@echo "  install                   - install mo files"
29
	@echo "  all			   - all of the above"
30
 
31
POTFILES = $(srcdir)/POTFILES.in \
32
	$(shell cat $(srcdir)/POTFILES.in)
33
 
34
pot: $(TD).pot
35
 
36
clean:
37
	rm -f *~ *.bak *.mo
38
 
39
# FIXME: The parameter --from-code is only needed if your sources contain
40
# any 8 bit data (even in comments).  UTF-8 is only a guess here, but it
41
# will at least accept any 8 bit data.
42
#
43
# The parameter "--language=perl" is not strictly needed because the
44
# source language of all our files will be auto-detected by xgettext
45
# by their filename extension.  You should even avoid this parameter
46
# if you want to extract strings from multiple source languages.
47
$(TD).pot: $(POTFILES)
48
	$(XGETTEXT) --output=$(srcdir)/$(TD).pox --from-code=utf-8 \
49
		--add-comments=TRANSLATORS: --files-from=$(srcdir)/POTFILES.in \
50
		--copyright-holder="$(COPYRIGHT_HOLDER)" \
51
		--msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
52
		--keyword --keyword='_' --keyword='$$__' --keyword=__ --keyword=__x \
53
		--keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \
54
		--keyword=__p:1c,2 --keyword=__np:1c,2,3 \
55
		--keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \
56
		--keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__ \
57
	rm -f $@ && mv $(TD).pox $@
58
 
59
install: $(MO_FILES)
60
	cd $(srcdir); \
61
	targetdir='$(libdir)/LocaleData'; \
62
	languages='$(LINGUAS)'; \
63
	for lang in $$languages; do \
64
		mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \
65
		dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \
66
		cat="$$lang.mo"; \
67
		echo "installing $$cat as $$dest"; \
68
		cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \
69
	done
70
 
71
update-mo: $(MO_FILES)
72
 
73
update-po:
74
	$(MAKE) $(TD).pot
75
	cd $(srcdir); \
76
        catalogs='$(CATALOGS)'; \
77
        for cat in $$catalogs; do \
78
          cat=`basename $$cat`; \
79
          lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
80
          mv $$lang.po $$lang.old.po; \
81
          echo "$$lang:"; \
82
          if $(MSGMERGE) $$lang.old.po $(TD).pot -o $$lang.po; then \
83
            rm -f $$lang.old.po; \
84
          else \
85
            echo "msgmerge for $$cat failed!"; \
86
            rm -f $$lang.po; \
87
            mv $$lang.old.po $$lang.po; \
88
          fi; \
89
        done
90
 
91
.SUFFIXES:
92
.SUFFIXES: .po .mo
93
 
94
.po.mo:
95
	$(MSGFMT) --check --statistics --verbose -o $@ $<
96