summaryrefslogtreecommitdiffstats
path: root/install/po/Makefile.in
blob: 0a8cd5e09866ca4620d761749e13b39b36afc62d (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
prefix = @prefix@
exec_prefix = ${prefix}
datarootdir = ${prefix}/share
datadir = ${datarootdir}
localedir = ${datarootdir}/locale

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL@ -m 644
MKDIR_P = @MKDIR_P@
XGETTEXT = @XGETTEXT@
MSGFMT = @MSGFMT@
MSGINIT = @MSGINIT@
MSGMERGE = @MSGMERGE@

DOMAIN = @GETTEXT_DOMAIN@
MSGMERGE_UPDATE = $(MSGMERGE) --update

COPYRIGHT_HOLDER = Red Hat
PACKAGE_NAME = $(DOMAIN)
PACKAGE_BUGREPORT = https://hosted.fedoraproject.org/projects/freeipa/newticket
XGETTEXT_OPTIONS = \
--add-comments="TRANSLATORS:" \
--copyright-holder="$(COPYRIGHT_HOLDER)" \
--package-name="$(PACKAGE_NAME)" \
--msgid-bugs-address="$(PACKAGE_BUGREPORT)"

languages = $(shell sed 's/\#.*//' LINGUAS) # The sed command removes comments
po_files = $(patsubst %, %.po, $(languages))
mo_files = $(patsubst %.po, %.mo, $(po_files))

PYTHON_POTFILES = \
     ../../ipa \
     ../../lite-server.py \
     ../../ipapython/config.py \
     ../../ipapython/sysrestore.py \
     ../../ipapython/ipasslfile.py \
     ../../ipapython/__init__.py \
     ../../ipapython/ipautil.py \
     ../../ipapython/certdb.py \
     ../../ipapython/ipavalidate.py \
     ../../ipapython/dnsclient.py \
     ../../ipapython/dogtag.py \
     ../../ipapython/nsslib.py \
     ../../ipapython/entity.py \
     ../../install/tools/ipa-replica-manage \
     ../../install/tools/ipa-server-certinstall \
     ../../install/tools/ipa-replica-install \
     ../../install/tools/ipa-nis-manage \
     ../../install/tools/ipa-upgradeconfig \
     ../../install/tools/ipa-replica-prepare \
     ../../install/tools/ipa-compat-manage \
     ../../install/tools/ipa-server-install \
     ../../install/tools/ipa-ldap-updater \
     ../../install/migration/migration.py \
     ../../ipalib/config.py \
     ../../ipalib/parameters.py \
     ../../ipalib/request.py \
     ../../ipalib/output.py \
     ../../ipalib/__init__.py \
     ../../ipalib/backend.py \
     ../../ipalib/pkcs10.py \
     ../../ipalib/x509.py \
     ../../ipalib/plugable.py \
     ../../ipalib/constants.py \
     ../../ipalib/aci.py \
     ../../ipalib/base.py \
     ../../ipalib/ipauuid.py \
     ../../ipalib/crud.py \
     ../../ipalib/cli.py \
     ../../ipalib/text.py \
     ../../ipalib/compat.py \
     ../../ipalib/frontend.py \
     ../../ipalib/rpc.py \
     ../../ipalib/errors.py \
     ../../ipalib/encoder.py \
     ../../ipalib/util.py \
     ../../ipalib/plugins/config.py \
     ../../ipalib/plugins/rolegroup.py \
     ../../ipalib/plugins/host.py \
     ../../ipalib/plugins/group.py \
     ../../ipalib/plugins/migration.py \
     ../../ipalib/plugins/xmlclient.py \
     ../../ipalib/plugins/service.py \
     ../../ipalib/plugins/passwd.py \
     ../../ipalib/plugins/__init__.py \
     ../../ipalib/plugins/virtual.py \
     ../../ipalib/plugins/hbac.py \
     ../../ipalib/plugins/cert.py \
     ../../ipalib/plugins/baseldap.py \
     ../../ipalib/plugins/aci.py \
     ../../ipalib/plugins/kerberos.py \
     ../../ipalib/plugins/krbtpolicy.py \
     ../../ipalib/plugins/dns.py \
     ../../ipalib/plugins/automount.py \
     ../../ipalib/plugins/netgroup.py \
     ../../ipalib/plugins/misc.py \
     ../../ipalib/plugins/user.py \
     ../../ipalib/plugins/taskgroup.py \
     ../../ipalib/plugins/hostgroup.py \
     ../../ipalib/plugins/pwpolicy.py \
     ../../ipaserver/__init__.py \
     ../../ipaserver/servercore.py \
     ../../ipaserver/ipautil.py \
     ../../ipaserver/rpcserver.py \
     ../../ipaserver/conn.py \
     ../../ipaserver/ipaldap.py \
     ../../ipaserver/install/installutils.py \
     ../../ipaserver/install/service.py \
     ../../ipaserver/install/ldapupdate.py \
     ../../ipaserver/install/__init__.py \
     ../../ipaserver/install/cainstance.py \
     ../../ipaserver/install/ntpinstance.py \
     ../../ipaserver/install/bindinstance.py \
     ../../ipaserver/install/krbinstance.py \
     ../../ipaserver/install/certs.py \
     ../../ipaserver/install/dsinstance.py \
     ../../ipaserver/install/replication.py \
     ../../ipaserver/install/httpinstance.py \
     ../../ipaserver/plugins/ldap2.py \
     ../../ipaserver/plugins/rabase.py \
     ../../ipaserver/plugins/selfsign.py \
     ../../ipaserver/plugins/__init__.py \
     ../../ipaserver/plugins/join.py \
     ../../ipaserver/plugins/ldapapi.py \
     ../../ipaserver/plugins/xmlserver.py \
     ../../ipaserver/plugins/dogtag.py \
     ../../contrib/RHEL4/ipachangeconf.py \
     ../../ipawebui/engine.py \
     ../../ipawebui/__init__.py \
     ../../ipawebui/widgets.py \
     ../../ipawebui/controllers.py \
     ../../ipa-client/ipaclient/ntpconf.py \
     ../../ipa-client/ipaclient/__init__.py \
     ../../ipa-client/ipaclient/ipachangeconf.py \
     ../../ipa-client/ipaclient/ipadiscovery.py \
     ../../ipa-client/ipa-install/ipa-client-install 

C_POTFILES = \
     ../../daemons/ipa-kpasswd/ipa_kpasswd.c \
     ../../daemons/ipa-slapi-plugins/ipa-enrollment/ipa_enrollment.c \
     ../../daemons/ipa-slapi-plugins/ipa-memberof/ipa-memberof.c \
     ../../daemons/ipa-slapi-plugins/ipa-memberof/ipa-memberof.h \
     ../../daemons/ipa-slapi-plugins/ipa-memberof/ipa-memberof_config.c \
     ../../daemons/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c \
     ../../daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync-config.c \
     ../../daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.c \
     ../../daemons/ipa-slapi-plugins/ipa-winsync/ipa-winsync.h \
     ../../ipa-client/config.c \
     ../../ipa-client/ipa-getkeytab.c \
     ../../ipa-client/ipa-join.c \
     ../../ipa-client/ipa-rmkeytab.c

POTFILES = $(PYTHON_POTFILES) $(C_POTFILES)

.SUFFIXES:
.SUFFIXES: .po .mo
.PHONY: all create-po update-po update-pot install mostlyclean clean distclean test_lang test

all: $(po_files)
	@

SUFFIXES = .po .mo

.po.mo:
	@echo Creating $@; \
	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@

$(po_files): $(DOMAIN).pot
	@if [ ! -f @a ]; then \
	    lang=`echo $@ | sed -r -e 's/\.po$$//'` # Strip .po suffix ; \
	    echo Creating nonexistent $@, you should add this file to your SCM repository; \
	    $(MSGINIT) --locale $$lang --no-translator -i $(DOMAIN).pot -o $@; \
	fi; \
	$(MSGMERGE) $@ -o $@ $(DOMAIN).pot

create-po: $(DOMAIN).pot
	@for po_file in $(po_files); do \
	    if [ ! -e $$po_file ]; then \
	        lang=`echo $$po_file | sed -r -e 's/\.po$$//'` # Strip .po suffix ; \
	        echo Creating nonexistent $$po_file, you should add this file to your SCM repository; \
	        $(MSGINIT) --locale $$lang --no-translator -i $(DOMAIN).pot -o $$po_file; \
	    fi; \
	done

$(DOMAIN).pot: $(POTFILES)
	$(MAKE) update-pot

update-po: update-pot
	$(MAKE) all

update-pot:
	rm -f $(DOMAIN).pot.update
	$(XGETTEXT) $(XGETTEXT_OPTIONS) \
	--output $(DOMAIN).pot.update \
	--language="python" \
	$(PYTHON_POTFILES) \
	&& \
	$(XGETTEXT) $(XGETTEXT_OPTIONS) \
	--output $(DOMAIN).pot.update \
	--join-existing \
	--language="c" \
	$(C_POTFILES) \
	&& \
	mv $(DOMAIN).pot.update $(DOMAIN).pot \
	&& \
	# Replace the charset with UTF-8 ; \
	sed -i -r -e 's%("Content-Type: text/plain; charset=)(.*)(\\n")%\1UTF-8\3%' $(DOMAIN).pot


install: $(mo_files)
	@for lang in $(languages); do \
	    dstdir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \
	    $(MKDIR_P) $$dstdir; \
	    $(INSTALL) $$lang.mo $$dstdir/$(DOMAIN).mo; \
	done

mostlyclean:
	rm -rf *.mo test.po test_locale

clean: mostlyclean

distclean: clean
	rm -f Makefile

# We test our translations by taking the original untranslated string
# (e.g. msgid) and prepend a prefix character and then append a suffix
# character. The test consists of asserting that the first character in the
# translated string is the prefix, the last character in the translated string
# is the suffix and the everything between the first and last character exactly
# matches the original msgid.
#
# We use unicode characters not in the ascii character set for the prefix and
# suffix to enhance the test. To make reading the translated string easier the
# prefix is the unicode right pointing arrow and the suffix left pointing arrow,
# thus the translated string looks like the original string enclosed in
# arrows. In ASCII art the string "foo" would render as:
# -->foo<--
#
# Unicode right pointing arrow: u'\u2192', utf-8 = '\xe2\x86\x92'
# Unicode left pointing arrow:  u'\u2190', utf-8 = '\xe2\x86\x90'
#
# The sed command below performs the prefix and suffix substitution.
#
# When msginit is invoked with an English target locale it copies the msgid
# into the msgstr. This is an undocumented feature of msginit. Otherwise the
# msgstr will be set to the empty string (i.e. untranslated). We depend on
# the msgid being copied to the msgstr.

test_lang:
	rm -rf test.po test_locale
	$(MSGINIT) --no-translator -i $(DOMAIN).pot -l en_US -o test.po
	sed -i -r -e 's/^msgstr[ \t]+"(.*)"[ \t]*$$/msgstr "\xe2\x86\x92\1\xe2\x86\x90"/' test.po
	$(MKDIR_P) test_locale/en_US/LC_MESSAGES
	$(MSGFMT) -o test_locale/en_US/LC_MESSAGES/ipa.mo test.po

test: test_lang
	./test_i18n.py