Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
22 | 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=__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 | --language=perl && \ |
||
58 | rm -f $@ && mv $(TD).pox $@ |
||
59 | |||
60 | install: $(MO_FILES) |
||
61 | cd $(srcdir); \ |
||
62 | targetdir='$(libdir)/LocaleData'; \ |
||
63 | languages='$(LINGUAS)'; \ |
||
64 | for lang in $$languages; do \ |
||
65 | mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \ |
||
66 | dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \ |
||
67 | cat="$$lang.mo"; \ |
||
68 | echo "installing $$cat as $$dest"; \ |
||
69 | cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \ |
||
70 | done |
||
71 | |||
72 | update-mo: $(MO_FILES) |
||
73 | |||
74 | update-po: |
||
75 | $(MAKE) $(TD).pot |
||
76 | cd $(srcdir); \ |
||
77 | catalogs='$(CATALOGS)'; \ |
||
78 | for cat in $$catalogs; do \ |
||
79 | cat=`basename $$cat`; \ |
||
80 | lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ |
||
81 | mv $$lang.po $$lang.old.po; \ |
||
82 | echo "$$lang:"; \ |
||
83 | if $(MSGMERGE) $$lang.old.po $(TD).pot -o $$lang.po; then \ |
||
84 | rm -f $$lang.old.po; \ |
||
85 | else \ |
||
86 | echo "msgmerge for $$cat failed!"; \ |
||
87 | rm -f $$lang.po; \ |
||
88 | mv $$lang.old.po $$lang.po; \ |
||
89 | fi; \ |
||
90 | done |
||
91 | |||
92 | .SUFFIXES: |
||
93 | .SUFFIXES: .po .mo |
||
94 | |||
95 | .po.mo: |
||
96 | $(MSGFMT) --check --statistics --verbose -o $@ $< |
||
97 |