Subversion Repositories LCARS

Rev

Rev 189 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
209 PointedEar 1
### Makefile for GNU gettext (.po) files
38 PointedEar 2
 
3
srcdir = .
209 PointedEar 4
targetdir = ./LocaleData
38 PointedEar 5
 
209 PointedEar 6
CATOBJEXT = .po
7
CATALOGS = $(addsuffix $(CATOBJEXT), $(LINGUAS))
38 PointedEar 8
MO_FILES = $(addsuffix .mo, $(LINGUAS))
9
 
209 PointedEar 10
XGETTEXT = xgettext
38 PointedEar 11
MSGMERGE = msgmerge
12
MSGFMT   = msgfmt
13
 
209 PointedEar 14
## Programming language: disable to let it be guessed based on filename suffix
15
prog_language = --language=PHP
16
 
17
## Character encoding of source files: disable for ASCII
18
encoding = --from-code=UTF-8
19
 
20
## Translation keyword: disable to let it be determined based on the prog. language
21
#		--keyword --keyword='_' --keyword='$$__' --keyword=__ --keyword=__x \
22
#		--keyword=__n:1,2 --keyword=__nx:1,2 --keyword=__xn:1,2 \
23
#		--keyword=__p:1c,2 --keyword=__np:1c,2,3 \
24
#		--keyword=__npx:1c,2,3 --keyword=N__ --keyword=N__n:1,2 \
25
#		--keyword=N__p:1c,2 --keyword=N__np:1c,2,3 --keyword=%__
26
keywords = --keyword=tr
27
 
38 PointedEar 28
include PACKAGE
29
 
30
TD = $(strip $(TEXTDOMAIN))
31
 
209 PointedEar 32
srcfiles_list = $(srcdir)/POTFILES.in
33
srcfiles = $(shell cat $(srcfiles_list))
38 PointedEar 34
 
209 PointedEar 35
.PHONY: help
38 PointedEar 36
help:
209 PointedEar 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'
38 PointedEar 43
 
209 PointedEar 44
.PHONY: pot
45
pot: $(TD).pot
38 PointedEar 46
 
209 PointedEar 47
.PHONY: update-po
48
update-po: $(CATALOGS)
38 PointedEar 49
 
209 PointedEar 50
.PHONY: update-mo
51
update-mo: $(MO_FILES)
38 PointedEar 52
 
209 PointedEar 53
.PHONY: install
38 PointedEar 54
install: $(MO_FILES)
209 PointedEar 55
	@cd $(srcdir); \
189 PointedEar 56
	targetdir='$(targetdir)'; \
38 PointedEar 57
	languages='$(LINGUAS)'; \
58
	for lang in $$languages; do \
59
		dest="$$targetdir/$$lang/LC_MESSAGES/$(TD).mo"; \
60
		cat="$$lang.mo"; \
209 PointedEar 61
		printf "Installing \`%s' as \`%s' ... " "$$cat" "$$dest"; \
62
		mkdir -p "$$targetdir/$$lang/LC_MESSAGES" || exit 1; \
63
		cp -f "$$cat" "$$dest" && chmod 644 "$$dest" || exit 1; \
64
		echo "done."; \
38 PointedEar 65
	done
66
 
209 PointedEar 67
.PHONY: all
68
all: install
38 PointedEar 69
 
209 PointedEar 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) \
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)" \
83
		--msgid-bugs-address="$(MSGID_BUGS_ADDRESS)"; \
84
	echo 'done.'
38 PointedEar 85
 
209 PointedEar 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
38 PointedEar 98
 
209 PointedEar 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"