| 1 |
#------------------------------------------------------------------------------- |
| 2 |
|
| 3 |
# Basic LINGUAS environment variable support |
| 4 |
|
| 5 |
ALL_LINGUAS := $(basename $(wildcard *.po)) |
| 6 |
|
| 7 |
ifneq ($(LINGUAS),) |
| 8 |
LINGUAS := $(filter $(ALL_LINGUAS), $(LINGUAS)) |
| 9 |
else |
| 10 |
LINGUAS := $(ALL_LINGUAS) |
| 11 |
endif |
| 12 |
|
| 13 |
#------------------------------------------------------------------------------- |
| 14 |
|
| 15 |
ROOT := .. |
| 16 |
|
| 17 |
DOMAIN := neverball |
| 18 |
MODIR := $(ROOT)/locale |
| 19 |
POFILES := $(LINGUAS:%=%.po) |
| 20 |
MOFILES := $(LINGUAS:%=$(MODIR)/%/LC_MESSAGES/$(DOMAIN).mo) |
| 21 |
SOURCES := \ |
| 22 |
$(wildcard $(ROOT)/ball/*.[ch]) \ |
| 23 |
$(wildcard $(ROOT)/share/*.[ch]) \ |
| 24 |
$(wildcard $(ROOT)/putt/*.[ch]) |
| 25 |
|
| 26 |
COPYRIGHT := Robert Kooima |
| 27 |
BUGADDR := [email protected] |
| 28 |
|
| 29 |
XGETTEXT := xgettext |
| 30 |
XGETTEXT_FLAGS := \ |
| 31 |
--add-comments=Translators --from-code=UTF-8 \ |
| 32 |
--keyword=_ \ |
| 33 |
--keyword=N_ \ |
| 34 |
--keyword=gt_prefix \ |
| 35 |
--keyword=gt_plural \ |
| 36 |
--default-domain="$(DOMAIN)" \ |
| 37 |
--copyright-holder="$(COPYRIGHT)" \ |
| 38 |
--msgid-bugs-address="$(BUGADDR)" |
| 39 |
|
| 40 |
#------------------------------------------------------------------------------ |
| 41 |
|
| 42 |
all: $(MOFILES) |
| 43 |
|
| 44 |
clean: |
| 45 |
rm -rf $(MODIR) |
| 46 |
|
| 47 |
#------------------------------------------------------------------------------ |
| 48 |
|
| 49 |
# Here it gets somewhat convoluted. Basic idea is: we want the |
| 50 |
# update-po target which is widely supported in autotools-based |
| 51 |
# internationalised packages. update-po unconditionally updates the POT |
| 52 |
# file, and thus forces PO and MO files to be updated as well. The |
| 53 |
# logic is loosely based on Makefile.in.in distributed with GNU gettext. |
| 54 |
|
| 55 |
update-po: $(DOMAIN).pot-update $(POFILES) $(MOFILES) |
| 56 |
|
| 57 |
$(MODIR)/%/LC_MESSAGES/$(DOMAIN).mo: %.po |
| 58 |
mkdir -p $(dir $@) |
| 59 |
msgfmt -c --statistics -o $@ $< |
| 60 |
|
| 61 |
%.po: $(DOMAIN).pot |
| 62 |
msgmerge -U --previous $@ $< |
| 63 |
touch $@ |
| 64 |
|
| 65 |
$(DOMAIN).pot $(DOMAIN).pot-update: |
| 66 |
$(XGETTEXT) $(XGETTEXT_FLAGS) -o $(DOMAIN).pot \ |
| 67 |
--directory="$(ROOT)" $(SOURCES:$(ROOT)/%=%) |
| 68 |
|
| 69 |
# Force encoding to UTF-8 |
| 70 |
sed "1,/^$$/ s/CHARSET/UTF-8/" < $(DOMAIN).pot > $(DOMAIN).pot.utf8 |
| 71 |
mv -f $(DOMAIN).pot.utf8 $(DOMAIN).pot |
| 72 |
|
| 73 |
sh $(ROOT)/scripts/extractpo.sh $(ROOT) >> $(DOMAIN).pot |
| 74 |
grep -v '^# ' < mtrl.pot >> $(DOMAIN).pot |
| 75 |
msguniq -o $(DOMAIN).pot.uniq $(DOMAIN).pot |
| 76 |
mv -f $(DOMAIN).pot.uniq $(DOMAIN).pot |
| 77 |
|
| 78 |
#------------------------------------------------------------------------------ |
| 79 |
|
| 80 |
stats: |
| 81 |
@find -name '*.po' | sort | xargs -n1 -I{} \ |
| 82 |
sh -c 'printf "{}: "; msgfmt -o /dev/null --statistics {}' |
| 83 |
|
| 84 |
#------------------------------------------------------------------------------ |
| 85 |
|