Skip to content

Commit a295a11

Browse files
committed
Add merge action; make template depend on source files
template used to be a command that always ran. Now it only runs if a file it gets strings from is changed. Other changes to reduce duplication and use make like it should be used.
1 parent f94ca8a commit a295a11

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

locale/Makefile

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,23 @@ help:
2323
@echo "$(MAKE) - build MO files. Run this before sdist"
2424
@echo "$(MAKE) dist - same as above"
2525
@echo "$(MAKE) template - update message template from sources"
26+
@echo "$(MAKE) merge - merge template into *.po files"
2627
@echo "$(MAKE) diff - see template differences in vi"
2728
@echo "$(MAKE) potest - check .po files for errors"
2829
@echo "$(MAKE) pytest - create locale files to run pytest"
2930
@echo "$(MAKE) locale.po - update message file from template"
3031
@echo "$(MAKE) locale.mo - compile individual message file"
3132
@echo "$(MAKE) help - this text"
33+
@echo ""
34+
@echo "Running make dist is the same as: make template merge dist"
3235

3336
# This will rebuild all MO files without updating their corresponding PO
3437
# files first. Run before creating Roundup distribution (hence the name).
3538
# PO files should be updated by their translators only, automatic update
3639
# adds unwanted fuzzy labels.
37-
dist:
38-
for file in $(PO_FILES); do \
39-
${MSGFMT} -o `basename $$file .po`.mo $$file; \
40-
done
40+
dist: $(MO_FILES)
4141

42-
template:
43-
${XPOT} -n -o $(TEMPLATE) $(SOURCES) 2>&1 | sed -e "/: Unexpected in Python source: #64 \`@'/d"
44-
45-
${RUN_PYTHON} ../roundup/cgi/TAL/talgettext.py -u $(TEMPLATE) \
46-
../share/roundup/templates/classic/html/*.html \
47-
../share/roundup/templates/devel/html/*.html \
48-
../share/roundup/templates/minimal/html/*.html \
49-
../share/roundup/templates/responsive/html/*.html
50-
VERSION="`sed -ne \"/__version__/s/.*'\(.*\)'.*/\1/p\" \
51-
../roundup/__init__.py`"; \
52-
${XGETTEXT} -j -w 80 -F \
53-
--package-name=Roundup \
54-
--package-version=$$VERSION \
55-
56-
--copyright-holder="See Roundup README.txt" \
57-
-o $(TEMPLATE) $(SOURCES)
42+
template: roundup.pot
5843

5944
pytest local_install: dist
6045
for file in $(MO_FILES); do \
@@ -68,20 +53,39 @@ diff:
6853
hg cat roundup.pot | diff -u -I '^\#: \.\./roundup.*$$' \
6954
-I '^#:\s*:[0-9]*.*$$' \
7055
- roundup.pot || exit 0
56+
merge: $(PO_FILES)
57+
7158
potest:
7259
sh -c 'for file in $(PO_FILES); do \
73-
${MSGFMT} -cv --statistics $$file; \
60+
${MSGFMT} -cv --statistics $$file; \
7461
done' 2>&1 | sort -k 2,2n
7562

7663
%.po: $(TEMPLATE)
77-
${MSGMERGE} -U --suffix=.bak $@ $<
78-
# update Project-Id-Version to match roundup.pot
79-
VER="`sed -ne \"/__version__/s/.*'\(.*\)'.*/\1/p\" \
64+
@echo "Rebuild $@"
65+
@${MSGMERGE} -U --suffix=.bak $@ $<
66+
@# update Project-Id-Version to match roundup.pot
67+
@VER="`sed -ne \"/__version__/s/.*'\(.*\)'.*/\1/p\" \
8068
../roundup/__init__.py`"; \
81-
sed -i.bak -e \
69+
sed -i -e \
8270
"s/^\(\"Project-Id-Version: Roundup\).*/\1 $${VER}\\\\n\"/" $@
8371

8472
%.mo: %.po
85-
${MSGFMT} --statistics -o $@ $<
73+
${MSGFMT} -o $@ $<
74+
75+
roundup.pot: $(SOURCES) $(TEMPLATES)
76+
${XPOT} -n -o $(TEMPLATE) $(SOURCES) 2>&1 | sed -e "/: Unexpected in Python source: #64 \`@'/d"
77+
78+
${RUN_PYTHON} ../roundup/cgi/TAL/talgettext.py -u $(TEMPLATE) \
79+
../share/roundup/templates/classic/html/*.html \
80+
../share/roundup/templates/devel/html/*.html \
81+
../share/roundup/templates/minimal/html/*.html \
82+
../share/roundup/templates/responsive/html/*.html
83+
VERSION="`sed -ne \"/__version__/s/.*'\(.*\)'.*/\1/p\" \
84+
../roundup/__init__.py`"; \
85+
${XGETTEXT} -j -w 80 -F \
86+
--package-name=Roundup \
87+
--package-version=$$VERSION \
88+
89+
--copyright-holder="See Roundup README.txt" \
90+
-o $(TEMPLATE) $(SOURCES)
8691

87-
roundup.pot: template

0 commit comments

Comments
 (0)