Debian Codegraph @

po/po-src/Rules-others

raw
1 # Additional make targets
2
3 .NOTPARALLEL:
4 DISTFILES.extra2 = Rules-others Makevars.in
5
6 #== Output statistics
7
8 l10n-stats:
9 @catalogs='$(CATALOGS)'; \
10 for cat in $$catalogs; do \
11 lang=`basename $$cat .gmo;`; \
12 stats=`msgfmt --statistics -o /dev/null $$lang.po 2>&1`; \
13 echo " $$lang: $$stats"; \
14 done
15
16 #== List translators
17
18 l10n-translators:
19 @catalogs='$(CATALOGS)'; \
20 for cat in $$catalogs; do \
21 lang=`basename $$cat .gmo;`; \
22 echo " $$lang:"; \
23 sed -n -E "/# Translators/,/msgid/s/# ([^<,]*).*/ \1/p" $$lang.po | tail -n +2 | sort -u; \
24 done
25
26 #== Clean obsolete strings and clear fuzzy flags
27
28 define clean_po =
29 msgattrib $(MSGCAT_OPTIONS) --no-obsolete --clear-fuzzy -o cleaned.po $(1); \
30 if ! cmp -s cleaned.po $(1) ; then \
31 count_obsolete=`grep -c "#~ msgid" $(1)`; \
32 count_fuzzy=`grep -c "#, fuzzy" $(1)`; \
33 echo "Cleaning $(1): $$count_obsolete obsolete entries, $$count_fuzzy fuzzy entries"; \
34 rm $(1) && mv cleaned.po $(1); \
35 else \
36 rm cleaned.po; \
37 fi
38 endef
39
40 l10n-clean:
41 @catalogs='$(CATALOGS)'; \
42 for cat in $$catalogs; do \
43 lang=`basename $$cat .gmo;`; \
44 $(call clean_po,$$lang.po); \
45 done
46
47 #== Regenerate POTFILES.in if the list of source files changed
48 #== (executed before the main update-po rule)
49
50 POTSRCS = $(foreach act, $(POTINCLUDES), -i $(act) $(foreach excl, $(POTEXCLUDES), -x $(act)/$(excl)))
51
52 update-po: update-pot
53 update-pot:
54 @if [ -x $(top_srcdir)/po/update-potfiles ] ; then \
55 $(top_srcdir)/po/update-potfiles $(POTSRCS) > POTFILES.inT ; \
56 if ! cmp -s POTFILES.inT POTFILES.in ; then \
57 rm POTFILES.in && mv POTFILES.inT POTFILES.in; \
58 echo "POTFILES.in updated"; \
59 else \
60 rm POTFILES.inT; \
61 fi; \
62 fi
63
64 #== Auto-install catalogs locally
65
66 update-gmo: stamp-li
67 all: stamp-li
68
69 stamp-li: $(GMOFILES)
70 @$(MAKE) local-install ; \
71 echo "touch stamp-li" && \
72 echo timestamp > stamp-liT && \
73 mv stamp-liT stamp-li; \
74
75 local-install:
76 @$(mkdir_p) $(top_srcdir)/locale &>/dev/null; \
77 if [ $$? -eq 0 ] ; then \
78 catalogs='$(CATALOGS)'; \
79 for cat in $$catalogs; do \
80 cat=`basename $$cat`; \
81 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
82 dir=$(top_srcdir)/locale/$$lang/LC_MESSAGES; \
83 $(mkdir_p) $$dir; \
84 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
85 $(INSTALL_DATA) $$realcat $$dir/$(DOMAIN).mo; \
86 echo "installing $$realcat as $$dir/$(DOMAIN).mo"; \
87 done; \
88 fi
89
90 .PHONY: local-install update-pot
91
92 #== Transifex synchronization
93
94 CURL = curl
95 TX = tx
96 TXORG = artic-games
97 TXPROJ = freedroid-rpg
98 TXPREFIX = src
99 TXPROPS = '{"category":["src"]}'
100 TXCRED = $(shell $(top_srcdir)/po/tx-credentials -t)
101 TXHOST = $(shell $(top_srcdir)/po/tx-credentials -r)
102 TXRSRC = freedroidrpg
103
104 comma:= ,
105 empty:=
106 space:= $(empty) $(empty)
107 TXLANGS = $(subst $(space),$(comma),$(foreach cata,$(CATALOGS),$(basename $(cata))))
108
109 # Update the transifex potfiles
110 #
111 # if the associated resource is not found in the tx config file:
112 # - the resource is created,
113 # - the pot file is pushed,
114 # - and the category is changed.
115 # else:
116 # - the pot file is pushed.
117 #
118 # Note: It is not yet possible to define a resource's category using tx-set
119 # (transifex-client version 0.10). We thus directly use the transifex remote
120 # API to change it once the resource has been pushed.
121
122 tx-update: $(DOMAIN).pot
123 @test " $(TXCRED)" = " " \
124 && { \
125 echo "You do not have a Transifex account"; \
126 exit 1; \
127 }; \
128 $(mkdir_p) tx-$(TXPREFIX); \
129 rsrc=$(TXRSRC); \
130 cp $(DOMAIN).pot tx-$(TXPREFIX)/$$rsrc.pot; \
131 if test -r tx-$(TXPREFIX)/$$rsrc.pot; then \
132 if ! $(TX) status $(TXPROJ).$(TXPREFIX)-$$rsrc >/dev/null 2>/dev/null; then \
133 echo "Creating $(TXPREFIX)-$$rsrc"; \
134 $(TX) add --file-filter="tx-$(TXPREFIX)/$$rsrc-<lang>.po" --type=PO --organization=$(TXORG) --project=$(TXPROJ) --resource=$(TXPREFIX)-$$rsrc tx-$(TXPREFIX)/$$rsrc.pot; \
135 if $(TX) push -s $(TXPROJ).$(TXPREFIX)-$$rsrc >/dev/null 2>/dev/null; then \
136 curl_output=`$(CURL) --request PATCH \
137 -s -o /dev/null -w "%{http_code}" \
138 --url $(TXHOST)/resources/o%3A$(TXORG)%3Ap%3A$(TXPROJ)%3Ar%3A$(TXPREFIX)-$$rsrc \
139 --header 'Accept: application/vnd.api+json' \
140 --header 'Authorization: Bearer $(TXCRED)' \
141 --header 'Content-Type: application/vnd.api+json' \
142 --data '{ "data": { "attributes": $(TXPROPS), \
143 "id": "o:$(TXORG):p:$(TXPREFIX):r:$(TXPREFIX)-$$rsrc", \
144 "type": "resources" } \
145 }'`; \
146 rtn=$$?; \
147 if test $$rtn -ne 0 -o " $$curl_output" != " 200"; then echo "Warning. Failed to set properties: error code $$curl_output"; fi; \
148 fi; \
149 else \
150 echo "Updating $(TXPREFIX)-$$rsrc"; \
151 $(TX) push -s $(TXPROJ).$(TXPREFIX)-$$rsrc; \
152 fi; \
153 fi; \
154 rm -rf tx-$(TXPREFIX)
155
156 # Pull the translations from transifex.
157 #
158 # For each lang:
159 # - the translation is fetched from transifex
160 # - merged into the game's po file of that lang
161 # - merged with the game's pot file (to synchronize comments and file positions)
162 #
163 # Note: the translated strings of a transifex file will override the
164 # translated strings of the game's file.
165
166 tx-pull:
167 @test " $(TXCRED)" = " " \
168 && { \
169 echo "You do not have a Transifex account"; \
170 exit 1; \
171 }; \
172 $(mkdir_p) tx-$(TXPREFIX); \
173 rsrc=$(TXRSRC); \
174 echo "Pulling $$rsrc-<lang>.po from transifex"; \
175 if $(TX) pull -l $(TXLANGS) $(TXPROJ).$(TXPREFIX)-$$rsrc; then \
176 catalogs='$(CATALOGS)'; \
177 for cat in $$catalogs; do \
178 cat=`basename $$cat`; \
179 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
180 if test -r tx-$(TXPREFIX)/$$rsrc-$$lang.po; then \
181 echo "Merging with $$lang.po"; \
182 msgcat $(MSGCAT_OPTIONS) --use-first -o $$lang.po tx-$(TXPREFIX)/$$rsrc-$$lang.po $$lang.po; \
183 else \
184 echo "Nothing to merge"; \
185 fi; \
186 $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $$lang.po $(DOMAIN).pot; \
187 $(call clean_po,$$lang.po); \
188 done; \
189 fi; \
190 rm -rf tx-$(TXPREFIX)
191
192 # Push the translations to transifex.
193 #
194 # For each lang:
195 # - the game's po is pushed to transifex
196
197 tx-push:
198 @test " $(TXCRED)" = " " \
199 && { \
200 echo "You do not have a Transifex account"; \
201 exit 1; \
202 }; \
203 test -e tx-push-granted \
204 || { \
205 echo "tx-push is a risky command."; \
206 echo "Create a 'tx-push-granted' file if you really want to execute it."; \
207 exit 1; \
208 }; \
209 rm -f tx-push-granted; \
210 $(mkdir_p) tx-$(TXPREFIX); \
211 catalogs='$(CATALOGS)'; \
212 rsrc=$(TXRSRC); \
213 for cat in $$catalogs; do \
214 cat=`basename $$cat`; \
215 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
216 echo "Pushing $$rsrc-$$lang.po to transifex"; \
217 cp $$lang.po tx/$$rsrc-$$lang.po; \
218 $(TX) push -l $$lang -t $(TXPROJ).$(TXPREFIX)-$$rsrc; \
219 done; \
220 rm -rf tx-$(TXPREFIX)
221
222 .PHONY: l10n-stats l10n-translators
223 .PHONY: tx-update tx-pull tx-push