comparison locale/Makefile @ 7402:bca4eaffb212

Rename GNUMakefile to Makefile
author John Rouillard <rouilj@ieee.org>
date Wed, 24 May 2023 20:40:31 -0400
parents locale/GNUmakefile@b222658a3504
children dce8f7799ecb
comparison
equal deleted inserted replaced
7401:6ebc9f6f5d8e 7402:bca4eaffb212
1 # Extract translatable strings from Roundup sources,
2 # update and compile all existing translations
3
4 # tool locations
5 XPOT ?= xpot
6 MSGFMT ?= msgfmt
7 MSGMERGE ?= msgmerge
8 XGETTEXT ?= xgettext
9 PYTHON ?= python3
10
11 TEMPLATE=roundup.pot
12
13 PACKAGES=$(shell find ../roundup ../share/roundup/templates -name '*.py' \
14 | sed -e 's,/[^/]*$$,,' | sort | uniq)
15 SOURCES=$(PACKAGES:=/*.py)
16 PO_FILES=$(wildcard *.po)
17 MO_FILES=$(PO_FILES:.po=.mo)
18 PYTHON_BUILD=../build/lib
19 RUN_PYTHON=PYTHONPATH=$(PYTHON_BUILD) $(PYTHON) -O
20
21 all: dist
22
23 help:
24 @echo "$(MAKE) - build MO files. Run this before sdist"
25 @echo "$(MAKE) dist - same as above"
26 @echo "$(MAKE) template - update message template from sources"
27 @echo "$(MAKE) diff - see template differences in vi"
28 @echo "$(MAKE) potest - check .po files for errors"
29 @echo "$(MAKE) pytest - create locale files to run pytest"
30 @echo "$(MAKE) locale.po - update message file from template"
31 @echo "$(MAKE) locale.mo - compile individual message file"
32 @echo "$(MAKE) help - this text"
33
34 # This will rebuild all MO files without updating their corresponding PO
35 # files first. Run before creating Roundup distribution (hence the name).
36 # PO files should be updated by their translators only, automatic update
37 # adds unwanted fuzzy labels.
38 dist:
39 for file in $(PO_FILES); do \
40 ${MSGFMT} -o `basename $$file .po`.mo $$file; \
41 done
42
43 template:
44 test -d $(PYTHON_BUILD) || (echo "Missing build directory $(PYTHON_BUILD). ln -s lib to build library"; exit 1)
45 ${XPOT} -n -o $(TEMPLATE) $(SOURCES)
46
47 ${RUN_PYTHON} ../roundup/cgi/TAL/talgettext.py -u $(TEMPLATE) \
48 ../share/roundup/templates/classic/html/*.html \
49 ../share/roundup/templates/devel/html/*.html \
50 ../share/roundup/templates/minimal/html/*.html \
51 ../share/roundup/templates/responsive/html/*.html
52 VERSION="`sed -ne \"/__version__/s/.*'\(.*\)'.*/\1/p\" \
53 ../build/lib/roundup/__init__.py`"; \
54 ${XGETTEXT} -j -w 80 -F \
55 --package-name=Roundup \
56 --package-version=$$VERSION \
57 --msgid-bugs-address=roundup-devel@lists.sourceforge.net \
58 --copyright-holder="See Roundup README.txt" \
59 -o $(TEMPLATE) $(SOURCES)
60
61 pytest local_install: dist
62 for file in $(MO_FILES); do \
63 lang=`basename $$file .mo`; \
64 mkdir -p locale/$$lang/LC_MESSAGES; \
65 cp $$file locale/$$lang/LC_MESSAGES/roundup.mo; \
66 done
67
68 # helps to check template file before check in
69 diff:
70 hg cat roundup.pot | diff -u -I '^\#: \.\./roundup.*$$' \
71 -I '^#:\s*:[0-9]*.*$$' \
72 - roundup.pot || exit 0
73 potest:
74 sh -c 'for file in $(PO_FILES); do \
75 ${MSGFMT} -cv --statistics $$file; \
76 done' 2>&1 | sort -k 2,2n
77
78 %.po: $(TEMPLATE)
79 ${MSGMERGE} -U --suffix=.bak $@ $<
80
81 %.mo: %.po
82 ${MSGFMT} --statistics -o $@ $<
83
84 roundup.pot: template

Roundup Issue Tracker: http://roundup-tracker.org/