Subversion Repositories LCARS

Rev

Rev 189 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 189 Rev 209
Line 1... Line 1...
1
# Makefile for various po files.
1
### Makefile for GNU gettext (.po) files
2
2
3
srcdir = .
3
srcdir = .
4
targetdir= ./LocaleData
4
targetdir = ./LocaleData
5
5
6
#CATALOGS = $(addsuffix .po, LINGUAS)
6
CATOBJEXT = .po
7
CATALOGS = $(LINGUAS)
7
CATALOGS = $(addsuffix $(CATOBJEXT), $(LINGUAS))
8
MO_FILES = $(addsuffix .mo, $(LINGUAS))
8
MO_FILES = $(addsuffix .mo, $(LINGUAS))
9
9
-
 
10
XGETTEXT = xgettext
10
MSGMERGE = msgmerge
11
MSGMERGE = msgmerge
11
MSGFMT   = msgfmt
12
MSGFMT   = msgfmt
12
XGETTEXT = xgettext
-
 
13
CATOBJEXT = .po
-
 
14
-
 
15
include PACKAGE
-
 
16
-
 
17
TD = $(strip $(TEXTDOMAIN))
-
 
18
13
-
 
14
## Programming language: disable to let it be guessed based on filename suffix
19
default: help
15
prog_language = --language=PHP
20
16
21
all: $(TD).pot update-po update-mo install
17
## Character encoding of source files: disable for ASCII
-
 
18
encoding = --from-code=UTF-8
22
19
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.
20
## Translation keyword: disable to let it be determined based on the prog. language
47
#		--keyword --keyword='_' --keyword='$$__' --keyword=__ --keyword=__x \
21
#		--keyword --keyword='_' --keyword='$$__' --keyword=__ --keyword=__x \
48
#		--keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \
22
#		--keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \
49
#		--keyword=__p:1c,2 --keyword=__np:1c,2,3 \
23
#		--keyword=__p:1c,2 --keyword=__np:1c,2,3 \
50
#		--keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \
24
#		--keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \
51
#		--keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__ \
25
#		--keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__ 
52
$(TD).pot: $(POTFILES)
26
keywords = --keyword=tr 
53
	$(XGETTEXT) --output=$(srcdir)/$(TD).pox --from-code=utf-8 \
-
 
54
		--add-comments=TRANSLATORS: --files-from=$(srcdir)/POTFILES.in \
-
 
-
 
27
55
		--package-name="$(PACKAGE_NAME)" \
28
include PACKAGE
56
		--package-version="$(PACKAGE_VERSION)" \
-
 
57
		--copyright-holder="$(COPYRIGHT_HOLDER)" \
-
 
58
		--msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
-
 
-
 
29
59
	rm -f $@ && mv $(TD).pox $@
30
TD = $(strip $(TEXTDOMAIN))
60
31
-
 
32
srcfiles_list = $(srcdir)/POTFILES.in
-
 
33
srcfiles = $(shell cat $(srcfiles_list)) 
-
 
34
-
 
35
.PHONY: help
-
 
36
help:
-
 
37
	@echo 'Available targets:'; \
-
 
38
	echo '  pot       - remake master catalog'; \
-
 
39
	echo '  update-po - merge po files'; \
-
 
40
	echo '  update-mo - regenerate mo files'; \
-
 
41
	echo '  install   - install mo files'; \
-
 
42
	echo '  all       - all of the above'
-
 
43
-
 
44
.PHONY: pot
-
 
45
pot: $(TD).pot
-
 
46
-
 
47
.PHONY: update-po
-
 
48
update-po: $(CATALOGS)
-
 
49
-
 
50
.PHONY: update-mo
-
 
51
update-mo: $(MO_FILES)
-
 
52
-
 
53
.PHONY: install
61
install: $(MO_FILES)
54
install: $(MO_FILES)
62
	cd $(srcdir); \
55
	@cd $(srcdir); \
63
	targetdir='$(targetdir)'; \
56
	targetdir='$(targetdir)'; \
64
	languages='$(LINGUAS)'; \
57
	languages='$(LINGUAS)'; \
65
	for lang in $$languages; do \
58
	for lang in $$languages; do \
66
		mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \
-
 
67
		dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \
59
		dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \
68
		cat="$$lang.mo"; \
60
		cat="$$lang.mo"; \
69
		echo "installing $$cat as $$dest"; \
61
		printf "Installing \`%s' as \`%s' ... " "$$cat" "$$dest"; \
-
 
62
		mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \
70
		cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \
63
		cp -f "$$cat" "$$dest" && chmod 644 "$$dest" || exit 1; \
-
 
64
		echo "done."; \
71
	done
65
	done
72
66
73
update-mo: $(MO_FILES)
-
 
74
-
 
75
update-po:
67
.PHONY: all
76
	$(MAKE) $(TD).pot
-
 
77
	cd $(srcdir); \
-
 
78
        catalogs='$(CATALOGS)'; \
-
 
79
        for cat in $$catalogs; do \
-
 
80
          cat=`basename $$cat`; \
-
 
81
          lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
-
 
82
          mv $$lang.po $$lang.old.po; \
-
 
83
          echo "$$lang:"; \
-
 
84
          if $(MSGMERGE) $$lang.old.po $(TD).pot -o $$lang.po; then \
-
 
85
            rm -f $$lang.old.po; \
-
 
86
          else \
-
 
87
            echo "msgmerge for $$cat failed!"; \
-
 
88
            rm -f $$lang.po; \
-
 
89
            mv $$lang.old.po $$lang.po; \
-
 
90
          fi; \
-
 
91
        done
68
all: install
92
-
 
93
.SUFFIXES:
-
 
94
.SUFFIXES: .po .mo
-
 
95
69
-
 
70
$(TD).pot: $(srcfiles)
-
 
71
	@printf "Generating \`%s' from source files ... " "$(TD).pot"; \
-
 
72
	$(XGETTEXT) \
-
 
73
		--files-from='$(srcfiles_list)' \
-
 
74
		--output=$(TD).pot \
-
 
75
		$(prog_language) \
96
.po.mo:
76
		$(encoding) \
-
 
77
		--join-existing \
-
 
78
		--add-comments=TRANSLATORS: \
-
 
79
		$(keywords) \
-
 
80
		--copyright-holder="$(COPYRIGHT_HOLDER)" \
-
 
81
		--package-name="$(PACKAGE_NAME)" \
-
 
82
		--package-version="$(PACKAGE_VERSION)" \
97
	$(MSGFMT) --check --statistics --verbose -o $@ $<
83
		--msgid-bugs-address="$(MSGID_BUGS_ADDRESS)"; \
-
 
84
	echo 'done.'
98
85
-
 
86
$(CATALOGS): $(TD).pot
-
 
87
	@printf "Updating \`%s' " "$@"; \
-
 
88
	po_file="$@"; \
-
 
89
	lang="$${po_file%$(CATOBJEXT)}"; \
-
 
90
	mv "$$lang.po" "$$lang.old.po"; \
-
 
91
	if $(MSGMERGE) -o "$$lang.po" "$$lang.old.po" "$(TD).pot"; then \
-
 
92
		rm -f "$$lang.old.po"; \
-
 
93
	else \
-
 
94
		echo >&2 "$(MSGMERGE) for \`$@' failed!"; \
-
 
95
		rm -f "$$lang.po"; \
-
 
96
		mv "$$lang.old.po" "$$lang.po"; \
-
 
97
	fi
-
 
98
-
 
99
$(MO_FILES): $(CATALOGS)
-
 
100
	@printf "Generating message catalog \`%s' ... " "$@";\
-
 
101
	mo_file="$@"; \
-
 
102
	po_file="$${mo_file%.mo}.po"; \
-
 
103
	$(MSGFMT) --check --statistics --verbose -o "$@" "$$po_file"
99
104