Source code taken from cacert-20120429.tar.bz2
[cacert.git] / locale / Makefile
1 #
2 # This Makefile will download the translations from our translation server (if
3 # they don't exist yet) and compile them. Try target help for more information
4 #
5
6 ################################################################################
7 ### Download ###
8 ################################################################################
9
10 DOWNLOAD_SERVER := translations.cacert.org
11 PO_URL_TEMPLATE := http://$(DOWNLOAD_SERVER)/export/cacert/%/messages.po
12
13 # Only use languages that have 10% or more of translated strings
14 AUTO_LANGS := \
15 en \
16 de \
17 nl \
18 pt_BR \
19 fr \
20 sv \
21 it \
22 es \
23 hu \
24 fi \
25 ja \
26 bg \
27 pt \
28 da \
29 pl \
30 zh_CN \
31 ru \
32 lv \
33 cs \
34 zh_TW \
35 el \
36 tr \
37 ar \
38
39 LANGS := \
40 ar \
41 bg \
42 cs \
43 da \
44 de \
45 el \
46 en \
47 es \
48 fa \
49 fi \
50 fr \
51 he \
52 hr \
53 hu \
54 id \
55 is \
56 it \
57 ja \
58 ka \
59 ko \
60 lv \
61 nb \
62 nl \
63 pl \
64 pt \
65 pt_BR \
66 ro \
67 ru \
68 sl \
69 sv \
70 th \
71 tr \
72 uk \
73 zh_CN \
74 zh_TW \
75
76
77 PO_FILE_TEMPLATE := %/messages.po
78 MO_FILE_TEMPLATE := %/LC_MESSAGES/messages.mo
79
80
81 # target: all - Build locales downloading po files
82 .PHONY: all
83 all: $(AUTO_LANGS)
84
85
86 # target: help - Display callable targets
87 .PHONY: help
88 help:
89 @egrep "^# target:" [Mm]akefile
90
91
92 # target: clean - remove the build directories
93 RM := rm -rf
94 .PHONY: clean
95 clean:
96 -$(RM) $(LANGS:%=%/)
97
98
99 # target: <lang> - build this particular language
100 .PHONY: $(LANGS)
101 $(LANGS): %: $(MO_FILE_TEMPLATE)
102
103
104 $(LANGS:%=$(MO_FILE_TEMPLATE)): $(MO_FILE_TEMPLATE): $(PO_FILE_TEMPLATE)
105 mkdir -p $(@D)
106 #filter obsolete translations
107 grep --invert-match '^#~ ' $< | \
108 msgfmt --check --output-file $@ -
109
110
111 .PHONY: $(LANGS:%=$(PO_FILE_TEMPLATE))
112 $(LANGS:%=$(PO_FILE_TEMPLATE)):
113 mkdir -p $(@D)
114 wget --output-document - '$(@:$(PO_FILE_TEMPLATE)=$(PO_URL_TEMPLATE))' | \
115 php -f escape_special_chars.php \
116 > $@
117
118
119
120
121 ################################################################################
122 ### Upload ###
123 ################################################################################
124
125 UPLOAD_SERVER := $(DOWNLOAD_SERVER)
126 SSH_USER := critical
127 SSH_OPTIONS :=
128 SCP_OPTIONS := $(SSH_OPTIONS)
129
130 FILE_OWNER := www-data
131
132 POT_UPLOAD_PATH := /var/www/Pootle/po/cacert/templates/messages.pot
133 MANAGE_PY := /var/www/Pootle/manage.py
134
135 VERSION := Production
136 DESCRITPION := LibreSSL - CAcert web application (localisation files)
137 COPYRIGHT_YEAR := 2004-$(shell date +\%Y)
138 PACKAGE := LibreSSL
139
140 GETTEXT_FILE_PATTERN := \
141 ../CommModule/client.pl \
142 ../includes/*.php \
143 ../includes/*/*.php \
144 ../pages/*/*.php \
145 ../scripts/*.php \
146 ../www/*.php \
147 ../www/*/*.php \
148 # ../tverify/*.php \
149 # ../tverify/*/*.php \
150
151 GETTEXT_FILES := $(wildcard $(GETTEXT_FILE_PATTERN))
152
153 # target: template - create the gettext template file, if you want to upload it
154 # target: onto the translation server you can directly use the
155 # target: target "upload"
156 .PHONY: template
157 template: messages.pot
158
159 # target: template.clean - remove anything that was created during the build of
160 # target: the template file
161 .PHONY: template.clean
162 template.clean:
163 -$(RM) messages.pot
164
165
166 # target: upload - upload the template to the translation server
167 .PHONY: upload
168 upload: messages.pot
169 scp $(SCP_OPTIONS) messages.pot $(SSH_USER)@$(UPLOAD_SERVER):$(POT_UPLOAD_PATH)
170 ssh $(SSH_OPTIONS) $(SSH_USER)@$(UPLOAD_SERVER) "sudo -u $(FILE_OWNER) pootle-update cacert"
171
172 # target: upload.clean - remove anything that was created during the upload
173 .PHONY: upload.clean
174 upload.clean: template.clean
175
176 messages.pot: $(GETTEXT_FILES)
177 xgettext --output - --sort-by-file --copyright-holder "CAcert Inc." \
178 --package-name "CAcert" --package-version "$(VERSION)" \
179 --msgid-bugs-address "translations-admin@cacert.org" $^ | \
180 # replace place holders in the lines before the first msgid\
181 sed '1,/^msgid/ { s/SOME DESCRIPTIVE TITLE/$(DESCRITPION)/; s/YEAR/$(COPYRIGHT_YEAR)/; s/PACKAGE/$(PACKAGE)/ }' \
182 > $@
183