summaryrefslogtreecommitdiff
path: root/makefiles/gmake/i18n.mk
blob: 660f62aee833fd191a5acc39febf41072f1652bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# handle localization stuff (gettext)
# (this follows roughly the way Postgresql handles NLS)
#
# requires:
# - CATALOG_NAME: name of the catalog (name of the library or program)
#                 will be installed as $(CATALOG_NAME).po in the localedir
# - GETTEXT_LANGUAGES: list of languages supported
# - GETTEXT_FILES: list of source files that contain message strings
# - GETTEXT_TRIGGERS: (optional) list of functions/macros that contain
#                     translatable strings
#
# provides:
# - target: init-po
# - target: update-po
# - taget: check-po

.PHONY: init-po update-po all_po clean_po install_po

ifeq "$(ENABLE_NLS)" "1"

PO_FILES = $(addprefix po/, $(addsuffix .po, $(GETTEXT_LANGUAGES)))
MO_FILES = $(addprefix po/, $(addsuffix .mo, $(GETTEXT_LANGUAGES)))

%.mo : %.po
	$(MSGFMT) -c -o $@ $<

po/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
	$(XGETTEXT) -n -F -d $(CATALOG_NAME) -o $@ \
		$(addprefix -k, $(GETTEXT_TRIGGERS)) --flag=_:1:pass-c-format \
		-d $(CATALOG_NAME) -n -F $(GETTEXT_FILES)

init-po: po/$(CATALOG_NAME).pot

clean_po:
	@-rm -f $(MO_FILES)
	@-rm -f po/$(CATALOG_NAME).pot

# hooks for the standard targets handling gettext stuff

all_po: $(MO_FILES)

install_po:
	@test -z "$(GETTEXT_LANGUAGES)" || \
		for lang in $(GETTEXT_LANGUAGES)""; do ( \
			echo "install po/$$lang.mo to $(localedir)/$$lang/LC_MESSAGES.." && \
			$(INSTALL) -d -m 755 $(localedir)/$$lang/LC_MESSAGES && \
			$(INSTALL) -m 644 po/$$lang.mo $(localedir)/$$lang/LC_MESSAGES/$(CATALOG_NAME).mo || exit 1 \
		) done

# TODO: sort out below

# merge the changes into the translation tables keeping existing
# translations
# msgmerge -s -U test_gettext_de_CH.po test_gettext.pot
#
# compile message files into binary format:
# msgfmt -c -v -o test_gettext_de.mo test_gettext_de.po

#test_gettext_de.po: test_gettext.pot
#	msgmerge -s -U $@ -i $<
#	touch $@

#test_gettext_de_CH.po: test_gettext.pot
#	msgmerge -s -U $@ -i $<
#	touch $@

# TODO: big cleanup for GCC compilation flags
# in older gcc (before 4.2.1) we can't switch off warnings selectivly with a
# prage. So gettext misses a format attribute which results in a warning
# test_gettext.c:81: warning: format not a string literal, argument types not checked
# (Solaris 8, NetBSD)
# on Solaris 10 we get a system header conflict if we don't specify -std=c99
#test_gettext.o : test_gettext.c
#	$(CC) -c -g -o $@ $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) $<

# LANG setting differs from platform to platform a little bit :-(
#ifeq "$(PLATFORM)" "LINUX"
#TEST_LANG = de_CH
#endif
#ifeq "$(PLATFORM)" "FREEBSD"
#TEST_LANG = de_CH.ISO8859-1
#endif
#ifeq "$(PLATFORM)" "OPENBSD"
#TEST_LANG = de_CH.ISO8859-1
#endif
#ifeq "$(PLATFORM)" "SUNOS"
#TEST_LANG = de_CH.iso_8859_1
#endif
#ifeq "$(PLATFORM)" "CYGWIN"
#TEST_LANG = de
#endif
#ifeq "$(PLATFORM)" "NETBSD"
#TEST_LANG = de
#endif
	
#local_test: test_gettext_de.mo test_gettext_de_CH.mo
#	@echo "Testing gettext.."
#	@mkdir -p locale/de_CH/LC_MESSAGES
#	@mkdir -p locale/de/LC_MESSAGES
#	@cp test_gettext_de.mo locale/de_CH/LC_MESSAGES/test_gettext.mo
#	@cp test_gettext_de.mo locale/de/LC_MESSAGES/test_gettext.mo
#	@LANG=$(TEST_LANG) ./test_gettext >/dev/null 2>&1

else

# No NLS supported wanted, provide dummy targets

all_po:
clean_po:
install_po:

endif