Skip to content

Commit 79e2ede

Browse files
committed
Makefile: "make translate" will only update circuitpython.pot
We can now rely on weblate to regularly update the individual language files from the template, so "make translate" only needs to update the template file circuitpython.pot. This is advantageous because updating the other files in locale/ was a frequent source of merge conflicts; resolving the conflict incorrectly was something that could easily occur (and did).
1 parent 47efd59 commit 79e2ede

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,25 @@ pseudoxml:
202202
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
203203

204204
# phony target so we always run
205+
.PHONY: all-source
205206
all-source:
206207

207208
locale/circuitpython.pot: all-source
208209
find $(TRANSLATE_SOURCES) -iname "*.c" -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o circuitpython.pot -p locale
209210

211+
# Historically, `make translate` updated the .pot file and ran msgmerge.
212+
# However, this was a frequent source of merge conflicts. Weblate can perform
213+
# msgmerge, so make translate merely update the translation template file.
214+
.PHONY: translate
210215
translate: locale/circuitpython.pot
216+
217+
# Note that normally we rely on weblate to perform msgmerge. This reduces the
218+
# chance of a merge conflict between developer changes (that only add and
219+
# remove source strings) and weblate changes (that only add and remove
220+
# translated strings from po files). However, in case this is legitimately
221+
# needed we preserve a rule to do it.
222+
.PHONY: msgmerge
223+
msgmerge:
211224
for po in $(shell ls locale/*.po); do msgmerge -U $$po -s --no-fuzzy-matching --add-location=file locale/circuitpython.pot; done
212225

213226
merge-translate:
@@ -216,8 +229,10 @@ merge-translate:
216229
git checkout --theirs -- locale/*
217230
make translate
218231

219-
check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
220-
$(PYTHON) tools/check_translations.py $^
232+
.PHONY: check-translate
233+
check-translate:
234+
find $(TRANSLATE_SOURCES) -iname "*.c" -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o circuitpython.pot.tmp -p locale
235+
$(PYTHON) tools/check_translations.py locale/circuitpython.pot.tmp locale/circuitpython.pot; status=$$?; rm -f locale/circuitpython.pot.tmp; exit $$status
221236

222237
stubs:
223238
@mkdir -p circuitpython-stubs

0 commit comments

Comments
 (0)