]> git.evergreen-ils.org Git - working/Evergreen.git/blob - build/i18n/Makefile
Also remove fm_IDL from the Makefile; fm_IDL.dtd is what we want
[working/Evergreen.git] / build / i18n / Makefile
1 PO=po
2 PROJECT=locale
3 LOCALE=fr-CA
4 STARTDIR=$(shell pwd)
5 POTLIST=$(shell ls -d po/*)
6 DTDDIR=../../Open-ILS/web/opac/locale
7 CHROME_PROPSDIR=../../Open-ILS/xul/staff_client/chrome/locale
8 SERVER_PROPSDIR=../../Open-ILS/xul/staff_client/server/locale
9 DOJO_LOCALE := $(shell echo ${LOCALE} | tr '[:upper:]-' '[:lower:]/')
10 DOJO_CON_SRC=../../Open-ILS/web/js/dojo/openils/conify/nls
11 DOJO_OPAC_SRC=../../Open-ILS/web/js/dojo/openils/opac/nls
12 DOJO_RPT_SRC=../../Open-ILS/web/js/dojo/openils/reports/nls
13 FMIDLSRC=../../Open-ILS/examples/fm_IDL.xml
14 FMIDLOUT=fm_IDL.dtd.pot
15 FMIDLENT=fm_IDL.xml
16 FMIDLENTITY=fm_IDL.dtd
17 EVTSRC=../../Open-ILS/src/extras/ils_events.xml
18 EVTOUT=ils_events.xml.pot
19 EVTPO=ils_events.xml.po
20 EVTXML=ils_events.xml
21 REPORTDIR=../../Open-ILS/web/reports/
22 SQLSRCDIR=../../Open-ILS/src/sql/Pg/
23 SQLSRCFILE=950.data.seed-values.sql
24 SQLPOT=db.seed.pot
25 SQLPO=db.seed.po
26 SQLOUT=950.data.seed-values
27 PROGRESS=--progress none
28
29 # This Makefile can be used to generate and update PO files for Evergreen,
30 # as well as generate updated SQL, fieldmapper IDL, DTD and JavaScript
31 # property files from the PO.
32 #
33 # Usage:
34 #
35 # To create a new set of untranslated PO files for locale ll-LL:
36 #   make LOCALE=ll-LL newpo
37 #
38 # To create a new set of POT files from the en-US source:
39 #   make LOCALE=ll-LL newpot
40 #
41 # To update a set of translated PO files with new or changed en-US strings:
42 #   make LOCALE=ll-LL updatepo
43 #
44 # To create a set of translated project files (DTDs, JavaScript message catalogs):
45 #   make LOCALE=ll-LL project
46 #
47 # To install a set of translated project files:
48 #   make LOCALE=ll-LL install
49
50 # Generate PO files from all POT files in PO for locale LOCALE
51 #
52 # The template for the standard GNU gettext format is
53 # template1/template1.pot
54 # template1/ll-LL.po
55 # template2/template2.pot
56 # template2/ll-LL.po
57
58 # So, iterate over the list of POT directories and 
59 # generate / update the specified locale PO file
60 newpo: 
61         @pot2po $(PROGRESS) -i po/admin.properties/admin.properties.pot -o $(PO)/admin.properties/$(LOCALE).po 
62         @pot2po $(PROGRESS) -i po/auth.properties/auth.properties.pot -o $(PO)/auth.properties/$(LOCALE).po 
63         @pot2po $(PROGRESS) -i po/cat.properties/cat.properties.pot -o $(PO)/cat.properties/$(LOCALE).po 
64         @pot2po $(PROGRESS) -i po/circ.properties/circ.properties.pot -o $(PO)/circ.properties/$(LOCALE).po 
65         @pot2po $(PROGRESS) -i po/common.properties/common.properties.pot -o $(PO)/common.properties/$(LOCALE).po 
66         @pot2po $(PROGRESS) -i po/conify.dtd/conify.dtd.pot -o $(PO)/conify.dtd/$(LOCALE).po 
67         @pot2po $(PROGRESS) -i po/conify.js/conify.js.pot -o $(PO)/conify.js/$(LOCALE).po 
68         @pot2po $(PROGRESS) -i po/db.seed/db.seed.pot -o $(PO)/db.seed/$(LOCALE).po 
69         @pot2po $(PROGRESS) -i po/fm_IDL.dtd/fm_IDL.dtd.pot -o $(PO)/fm_IDL.dtd/$(LOCALE).po 
70         @pot2po $(PROGRESS) -i po/ils_events.xml/ils_events.xml.pot -o $(PO)/ils_events.xml/$(LOCALE).po 
71         @pot2po $(PROGRESS) -i po/lang.dtd/lang.dtd.pot -o $(PO)/lang.dtd/$(LOCALE).po 
72         @pot2po $(PROGRESS) -i po/multiclass_search_help.html/multiclass_search_help.html.pot -o $(PO)/multiclass_search_help.html/$(LOCALE).po 
73         @pot2po $(PROGRESS) -i po/offline.properties/offline.properties.pot -o $(PO)/offline.properties/$(LOCALE).po 
74         @pot2po $(PROGRESS) -i po/opac.dtd/opac.dtd.pot -o $(PO)/opac.dtd/$(LOCALE).po 
75         @pot2po $(PROGRESS) -i po/opac.js/opac.js.pot -o $(PO)/opac.js/$(LOCALE).po 
76         @pot2po $(PROGRESS) -i po/patron.properties/patron.properties.pot -o $(PO)/patron.properties/$(LOCALE).po 
77         @pot2po $(PROGRESS) -i po/reports.dtd/reports.dtd.pot -o $(PO)/reports.dtd/$(LOCALE).po 
78         @pot2po $(PROGRESS) -i po/reports.js/reports.js.pot -o $(PO)/reports.js/$(LOCALE).po 
79         @pot2po $(PROGRESS) -i po/vandelay.dtd/vandelay.dtd.pot -o $(PO)/vandelay.dtd/$(LOCALE).po 
80         @echo "Generated new PO files for locale $(LOCALE)"
81
82 # Generate a new set of POT files and entityized fieldmapper IDL
83 newpot: dtds2pot fmidl2pot fmidl2fmidlent ils2pot props2pot sql2pot dojo2pot
84         @echo "Generated new POT files"
85
86 # Generate DTD, JavaScript message catalogs, fieldmapper IDL,
87 # and SQL insert files from PO for locale LOCALE
88 project: prep_output po2dtds po2props po2sql fmidlpo2entity po2ils po2dojo
89         @echo "Generated project files for locale $(LOCALE)"
90
91 # Update PO files with new and changed strings from POT files
92 updatepo: prep_output  
93         @pot2po $(PROGRESS) -i po/admin.properties/admin.properties.pot -o $(PO)/admin.properties/$(LOCALE).po  -t $(PO)/admin.properties/$(LOCALE).po 
94         @pot2po $(PROGRESS) -i po/auth.properties/auth.properties.pot -o $(PO)/auth.properties/$(LOCALE).po  -t $(PO)/auth.properties/$(LOCALE).po 
95         @pot2po $(PROGRESS) -i po/cat.properties/cat.properties.pot -o $(PO)/cat.properties/$(LOCALE).po  -t $(PO)/cat.properties/$(LOCALE).po 
96         @pot2po $(PROGRESS) -i po/circ.properties/circ.properties.pot -o $(PO)/circ.properties/$(LOCALE).po  -t $(PO)/circ.properties/$(LOCALE).po 
97         @pot2po $(PROGRESS) -i po/common.properties/common.properties.pot -o $(PO)/common.properties/$(LOCALE).po  -t $(PO)/common.properties/$(LOCALE).po 
98         @pot2po $(PROGRESS) -i po/conify.dtd/conify.dtd.pot -o $(PO)/conify.dtd/$(LOCALE).po  -t $(PO)/conify.dtd/$(LOCALE).po 
99         @pot2po $(PROGRESS) -i po/conify.js/conify.js.pot -o $(PO)/conify.js/$(LOCALE).po  -t $(PO)/conify.js/$(LOCALE).po 
100         @pot2po $(PROGRESS) -i po/db.seed/db.seed.pot -o $(PO)/db.seed/$(LOCALE).po  -t $(PO)/db.seed/$(LOCALE).po 
101         @pot2po $(PROGRESS) -i po/fm_IDL.dtd/fm_IDL.dtd.pot -o $(PO)/fm_IDL.dtd/$(LOCALE).po  -t $(PO)/fm_IDL.dtd/$(LOCALE).po 
102         @pot2po $(PROGRESS) -i po/ils_events.xml/ils_events.xml.pot -o $(PO)/ils_events.xml/$(LOCALE).po  -t $(PO)/ils_events.xml/$(LOCALE).po 
103         @pot2po $(PROGRESS) -i po/lang.dtd/lang.dtd.pot -o $(PO)/lang.dtd/$(LOCALE).po  -t $(PO)/lang.dtd/$(LOCALE).po 
104         @pot2po $(PROGRESS) -i po/multiclass_search_help.html/multiclass_search_help.html.pot -o $(PO)/multiclass_search_help.html/$(LOCALE).po  -t $(PO)/multiclass_search_help.html/$(LOCALE).po 
105         @pot2po $(PROGRESS) -i po/offline.properties/offline.properties.pot -o $(PO)/offline.properties/$(LOCALE).po  -t $(PO)/offline.properties/$(LOCALE).po 
106         @pot2po $(PROGRESS) -i po/opac.dtd/opac.dtd.pot -o $(PO)/opac.dtd/$(LOCALE).po  -t $(PO)/opac.dtd/$(LOCALE).po 
107         @pot2po $(PROGRESS) -i po/opac.js/opac.js.pot -o $(PO)/opac.js/$(LOCALE).po  -t $(PO)/opac.js/$(LOCALE).po 
108         @pot2po $(PROGRESS) -i po/patron.properties/patron.properties.pot -o $(PO)/patron.properties/$(LOCALE).po  -t $(PO)/patron.properties/$(LOCALE).po 
109         @pot2po $(PROGRESS) -i po/reports.dtd/reports.dtd.pot -o $(PO)/reports.dtd/$(LOCALE).po  -t $(PO)/reports.dtd/$(LOCALE).po 
110         @pot2po $(PROGRESS) -i po/reports.js/reports.js.pot -o $(PO)/reports.js/$(LOCALE).po  -t $(PO)/reports.js/$(LOCALE).po 
111         @pot2po $(PROGRESS) -i po/vandelay.dtd/vandelay.dtd.pot -o $(PO)/vandelay.dtd/$(LOCALE).po  -t $(PO)/vandelay.dtd/$(LOCALE).po 
112         @echo "Updated PO files for locale $(LOCALE)"
113
114 dtds2pot:
115         @moz2po -P $(PROGRESS) -o $(PO)/conify.dtd/conify.dtd.pot -i $(DTDDIR)/en-US/conify.dtd 2>&1
116         @moz2po -P $(PROGRESS) -o $(PO)/lang.dtd/lang.dtd.pot -i $(DTDDIR)/en-US/lang.dtd 2>&1
117         @moz2po -P $(PROGRESS) -o $(PO)/opac.dtd/opac.dtd.pot -i $(DTDDIR)/en-US/opac.dtd 2>&1
118         @moz2po -P $(PROGRESS) -o $(PO)/reports.dtd/reports.dtd.pot -i $(DTDDIR)/en-US/reports.dtd 2>&1
119         @moz2po -P $(PROGRESS) -o $(PO)/vandelay.dtd/vandelay.dtd.pot -i $(DTDDIR)/en-US/vandelay.dtd 2>&1
120
121 dojo2pot:
122         @scripts/dojo_resource.py --pot $(DOJO_CON_SRC)/conify.js --output $(PO)/conify.js/conify.js.pot
123         @scripts/dojo_resource.py --pot $(DOJO_OPAC_SRC)/opac.js --output $(PO)/opac.js/opac.js.pot
124         @scripts/dojo_resource.py --pot $(DOJO_RPT_SRC)/reports.js --output $(PO)/reports.js/reports.js.pot
125
126 po2dojo:
127         @mkdir -p locale/$(LOCALE)
128         @scripts/dojo_resource.py --create $(PO)/conify.js/$(LOCALE).po --output $(PROJECT)/$(LOCALE)/conify.js
129         @scripts/dojo_resource.py --create $(PO)/opac.js/$(LOCALE).po --output $(PROJECT)/$(LOCALE)/opac.js
130         @scripts/dojo_resource.py --create $(PO)/reports.js/$(LOCALE).po --output $(PROJECT)/$(LOCALE)/reports.js
131
132 ils2pot:
133         @scripts/ils_events.py --pot $(EVTSRC) --output $(PO)/ils_events.xml/$(EVTOUT)
134
135 po2ils:
136         @mkdir -p locale/$(LOCALE)
137         @scripts/ils_events.py --create $(PO)/ils_events.xml/$(LOCALE).po --locale $(LOCALE) --output $(PROJECT)/$(LOCALE)/$(EVTXML) 
138
139 props2pot:
140         @mkdir -p locale/$(LOCALE)
141         @moz2po -P $(PROGRESS) -o $(PO)/auth.properties/auth.properties.pot -i $(CHROME_PROPSDIR)/en-US/auth.properties 2>&1
142         @moz2po -P $(PROGRESS) -o $(PO)/offline.properties/offline.properties.pot -i $(CHROME_PROPSDIR)/en-US/offline.properties 2>&1
143         @moz2po -P $(PROGRESS) -o $(PO)/admin.properties/admin.properties.pot -i $(SERVER_PROPSDIR)/en-US/admin.properties 2>&1
144         @moz2po -P $(PROGRESS) -o $(PO)/cat.properties/cat.properties.pot -i $(SERVER_PROPSDIR)/en-US/cat.properties 2>&1
145         @moz2po -P $(PROGRESS) -o $(PO)/circ.properties/circ.properties.pot -i $(SERVER_PROPSDIR)/en-US/circ.properties 2>&1
146         @moz2po -P $(PROGRESS) -o $(PO)/common.properties/common.properties.pot -i $(SERVER_PROPSDIR)/en-US/common.properties 2>&1
147         @moz2po -P $(PROGRESS) -o $(PO)/multiclass_search_help.html/multiclass_search_help.html.pot -i $(SERVER_PROPSDIR)/en-US/multiclass_search_help.html 2>&1
148         @moz2po -P $(PROGRESS) -o $(PO)/patron.properties/patron.properties.pot -i $(SERVER_PROPSDIR)/en-US/patron.properties 2>&1
149
150 # There are some hacky things we need to do to make po2moz happy,
151 # like ensure that the .po file has either ".dtd" or ".properties" in
152 # the name to generate the appropriate output, even though that breaks
153 # GNU gettext recommended layout of foo.dtd/ll-LL.po
154 prep_output:
155         @mkdir -p locale/$(LOCALE)
156         @for i in `ls -d $(PO)/*.dtd`; do cd $(STARTDIR)/$$i && ln -sf $(LOCALE).po $(LOCALE).dtd.po; done
157         @for i in `ls -d $(PO)/*.properties`; do cd $(STARTDIR)/$$i && ln -sf $(LOCALE).po $(LOCALE).properties.po; done
158         @for i in `ls -d $(PO)/*.html`; do cd $(STARTDIR)/$$i && ln -sf $(LOCALE).po $(LOCALE).html.po; done
159         @cd $(STARTDIR)
160
161 po2dtds:
162         @mkdir -p locale/$(LOCALE)
163         @po2moz $(PROGRESS) -i $(PO)/conify.dtd/$(LOCALE).dtd.po -o $(PROJECT)/$(LOCALE)/conify.dtd -t $(DTDDIR)/en-US/conify.dtd 2>&1
164         @po2moz $(PROGRESS) -i $(PO)/lang.dtd/$(LOCALE).dtd.po -o $(PROJECT)/$(LOCALE)/lang.dtd -t $(DTDDIR)/en-US/lang.dtd 2>&1
165         @po2moz $(PROGRESS) -i $(PO)/opac.dtd/$(LOCALE).dtd.po -o $(PROJECT)/$(LOCALE)/opac.dtd -t $(DTDDIR)/en-US/opac.dtd 2>&1
166         @po2moz $(PROGRESS) -i $(PO)/reports.dtd/$(LOCALE).dtd.po -o $(PROJECT)/$(LOCALE)/reports.dtd -t $(DTDDIR)/en-US/reports.dtd 2>&1
167         @po2moz $(PROGRESS) -i $(PO)/vandelay.dtd/$(LOCALE).dtd.po -o $(PROJECT)/$(LOCALE)/vandelay.dtd -t $(DTDDIR)/en-US/vandelay.dtd 2>&1
168
169 po2props:
170         @po2moz $(PROGRESS) -i $(PO)/auth.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/auth.properties -t $(CHROME_PROPSDIR)/en-US/auth.properties 2>&1
171         @po2moz $(PROGRESS) -i $(PO)/offline.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/offline.properties -t $(CHROME_PROPSDIR)/en-US/offline.properties 2>&1
172         @po2moz $(PROGRESS) -i $(PO)/admin.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/admin.properties -t $(SERVER_PROPSDIR)/en-US/admin.properties 2>&1
173         @po2moz $(PROGRESS) -i $(PO)/cat.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/cat.properties -t $(SERVER_PROPSDIR)/en-US/cat.properties 2>&1
174         @po2moz $(PROGRESS) -i $(PO)/circ.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/circ.properties -t $(SERVER_PROPSDIR)/en-US/circ.properties 2>&1
175         @po2moz $(PROGRESS) -i $(PO)/common.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/common.properties -t $(SERVER_PROPSDIR)/en-US/common.properties 2>&1
176         @po2moz $(PROGRESS) -i $(PO)/multiclass_search_help.html/$(LOCALE).html.po -o $(PROJECT)/$(LOCALE)/multiclass_search_help.html -t $(SERVER_PROPSDIR)/en-US/multiclass_search_help.html 2>&1
177         @po2moz $(PROGRESS) -i $(PO)/patron.properties/$(LOCALE).properties.po -o $(PROJECT)/$(LOCALE)/patron.properties -t $(SERVER_PROPSDIR)/en-US/patron.properties 2>&1
178
179 sql2pot:
180         @scripts/db-seed-i18n.py --pot $(SQLSRCDIR)/$(SQLSRCFILE) --output $(PO)/db.seed/$(SQLPOT)
181 #       @msghack --empty -o $(PO)/$(SQLPOT) $(PO)/$(SQLPOT)
182
183 po2sql:
184         @mkdir -p locale/$(LOCALE)
185         @scripts/db-seed-i18n.py --sql $(PO)/db.seed/$(LOCALE).po --locale $(LOCALE) --output $(PROJECT)/$(LOCALE)/$(SQLOUT).sql
186
187 # Generate a fieldmapper IDL file that uses entities instead of hard-coded strings
188 fmidl2fmidlent:
189         @scripts/fieldmapper.py --convert $(FMIDLSRC) --output $(PO)/$(FMIDLENT)
190
191 # Generate a POT file for translating the entity values
192 fmidl2pot:
193         @scripts/fieldmapper.py --pot $(FMIDLSRC) --output $(PO)/fm_IDL.dtd/$(FMIDLOUT)
194
195 # Generate a set of entity declarations from a PO file
196 fmidlpo2entity:
197         @mkdir -p locale/$(LOCALE)
198         @scripts/fieldmapper.py --entity $(PO)/fm_IDL.dtd/$(LOCALE).po --output $(PROJECT)/$(LOCALE)/$(FMIDLENTITY)
199
200 # Generate en-US DTD from a POT file; required if any other locale is installed
201 fmidlpo2entity-en:
202         mkdir -p $(PROJECT)/en-US
203         @scripts/fieldmapper.py --entity $(PO)/fm_IDL.dtd/$(FMIDLOUT) --output $(PROJECT)/en-US/$(FMIDLENTITY)
204         cp $(PROJECT)/en-US/$(FMIDLENTITY) $(DTDDIR)/en-US/
205
206 # Install updated project files to their corresponding location in the source tree
207 install: updatepo project fmidl2fmidlent fmidlpo2entity-en
208         mkdir -p $(CHROME_PROPSDIR)/$(LOCALE)
209         cp $(PROJECT)/$(LOCALE)/auth.properties $(CHROME_PROPSDIR)/$(LOCALE)/.
210         cp $(PROJECT)/$(LOCALE)/offline.properties $(CHROME_PROPSDIR)/$(LOCALE)/.
211         mkdir -p $(SERVER_PROPSDIR)/$(LOCALE)
212         cp $(PROJECT)/$(LOCALE)/admin.properties $(SERVER_PROPSDIR)/$(LOCALE)/.
213         cp $(PROJECT)/$(LOCALE)/cat.properties $(SERVER_PROPSDIR)/$(LOCALE)/.
214         cp $(PROJECT)/$(LOCALE)/circ.properties $(SERVER_PROPSDIR)/$(LOCALE)/.
215         cp $(PROJECT)/$(LOCALE)/common.properties $(SERVER_PROPSDIR)/$(LOCALE)/.
216         cp $(PROJECT)/$(LOCALE)/multiclass_search_help.html $(SERVER_PROPSDIR)/$(LOCALE)/.
217         cp $(PROJECT)/$(LOCALE)/patron.properties $(SERVER_PROPSDIR)/$(LOCALE)/.
218         mkdir -p $(DTDDIR)/$(LOCALE)
219         cp $(PROJECT)/$(LOCALE)/conify.dtd $(DTDDIR)/$(LOCALE)/
220         cp $(PROJECT)/$(LOCALE)/lang.dtd $(CHROME_PROPSDIR)/$(LOCALE)/
221         cp $(PROJECT)/$(LOCALE)/lang.dtd $(DTDDIR)/$(LOCALE)/
222         cp $(PROJECT)/$(LOCALE)/opac.dtd $(DTDDIR)/$(LOCALE)/
223         cp $(PROJECT)/$(LOCALE)/reports.dtd $(DTDDIR)/$(LOCALE)/
224         cp $(PROJECT)/$(LOCALE)/vandelay.dtd $(DTDDIR)/$(LOCALE)/
225         cp $(PROJECT)/$(LOCALE)/$(FMIDLENTITY) $(DTDDIR)/$(LOCALE)/
226         @scripts/merge_ils_events.py --master $(EVTSRC) --localization $(PROJECT)/$(LOCALE)/$(EVTXML) --output $(EVTSRC)
227         cp $(PROJECT)/$(LOCALE)/$(SQLOUT).sql $(SQLSRCDIR)/$(SQLOUT)-$(LOCALE).sql
228         cp $(PO)/$(FMIDLENT) $(REPORTDIR)/$(FMIDLENT)
229         mkdir -p $(DOJO_CON_SRC)/$(DOJO_LOCALE)
230         cp $(PROJECT)/$(LOCALE)/conify.js $(DOJO_CON_SRC)/$(DOJO_LOCALE)/conify.js
231         mkdir -p $(DOJO_OPAC_SRC)/$(DOJO_LOCALE)
232         cp $(PROJECT)/$(LOCALE)/opac.js $(DOJO_OPAC_SRC)/$(DOJO_LOCALE)/opac.js
233         mkdir -p $(DOJO_RPT_SRC)/$(DOJO_LOCALE)
234         cp $(PROJECT)/$(LOCALE)/reports.js $(DOJO_RPT_SRC)/$(DOJO_LOCALE)/reports.js
235
236 install_all_locales: newpo newpot
237         for i in `ls po/*/*po|grep -v en-US | cut -f3 -d'/' | cut -f1 -d. | sort | uniq`; \
238         do \
239         make LOCALE=$$i install; \
240         RC=$$?; \
241         if [ "$$RC" -gt 0 ]; \
242         then echo $$RC; exit $$RC; \
243         fi; done