bug 1019: Do not allow logged in users to spam someone else
[cacert-devel.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 # convert UTF-8 characters to HTML entities \
116 php -r 'while (!feof(STDIN)) echo mb_convert_encoding(fgets(STDIN), "HTML-ENTITIES", "UTF-8");' \
117 > $@
118
119
120
121
122 ################################################################################
123 ### Upload ###
124 ################################################################################
125
126 UPLOAD_SERVER := $(DOWNLOAD_SERVER)
127 SSH_USER := critical
128 SSH_OPTIONS :=
129 SCP_OPTIONS := $(SSH_OPTIONS)
130
131 FILE_OWNER := www-data
132
133 POT_UPLOAD_PATH := /var/www/Pootle/po/cacert/templates/messages.pot
134 MANAGE_PY := /var/www/Pootle/manage.py
135
136 VERSION := Production
137 DESCRITPION := LibreSSL - CAcert web application (localisation files)
138 COPYRIGHT_YEAR := 2004-$(shell date +\%Y)
139 PACKAGE := LibreSSL
140
141 GETTEXT_FILE_PATTERN := \
142 ../CommModule/client.pl \
143 ../includes/*.php \
144 ../includes/*/*.php \
145 ../pages/*/*.php \
146 ../scripts/*.php \
147 ../www/*.php \
148 ../www/*/*.php \
149 # ../tverify/*.php \
150 # ../tverify/*/*.php \
151
152 GETTEXT_FILES := $(wildcard $(GETTEXT_FILE_PATTERN))
153
154 # target: template - create the gettext template file, if you want to upload it
155 # target: onto the translation server you can directly use the
156 # target: target "upload"
157 .PHONY: template
158 template: messages.pot
159
160 # target: template.clean - remove anything that was created during the build of
161 # target: the template file
162 .PHONY: template.clean
163 template.clean:
164 -$(RM) messages.pot
165
166
167 # target: upload - upload the template to the translation server
168 .PHONY: upload
169 upload: messages.pot
170 scp $(SCP_OPTIONS) messages.pot $(SSH_USER)@$(UPLOAD_SERVER):$(POT_UPLOAD_PATH)
171 ssh $(SSH_OPTIONS) $(SSH_USER)@$(UPLOAD_SERVER) "sudo -u $(FILE_OWNER) pootle-update cacert"
172
173 # target: upload.clean - remove anything that was created during the upload
174 .PHONY: upload.clean
175 upload.clean: template.clean
176
177 messages.pot: $(GETTEXT_FILES)
178 xgettext --output - --sort-by-file --copyright-holder "CAcert Inc." \
179 --package-name "CAcert" --package-version "$(VERSION)" \
180 --msgid-bugs-address "translations-admin@cacert.org" $^ | \
181 # replace place holders in the lines before the first msgid\
182 sed '1,/^msgid/ { s/SOME DESCRIPTIVE TITLE/$(DESCRITPION)/; s/YEAR/$(COPYRIGHT_YEAR)/; s/PACKAGE/$(PACKAGE)/ }' \
183 > $@
184