aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 981bb747bccff78b058824d6042f0eec7643eeb6 (plain) (blame)
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
# This file is in the public domain.

# All: build HTML pages in all languages and compile the
# TypeScript logic in web-common.

include config.mk

all: locale template

# Extract translateable strings from jinja2 templates.
locale/messages.pot: *.j2 common/*.j2.inc
	pybabel extract -F locale/babel.map -o locale/messages.pot .

# Update translation (.po) files with new strings.
locale-update: locale/messages.pot
	msgmerge -U -m --previous locale/en/LC_MESSAGES/messages.po locale/messages.pot
	msgmerge -U -m --previous locale/de/LC_MESSAGES/messages.po locale/messages.pot
	msgmerge -U -m --previous locale/fr/LC_MESSAGES/messages.po locale/messages.pot
	msgmerge -U -m --previous locale/es/LC_MESSAGES/messages.po locale/messages.pot
	msgmerge -U -m --previous locale/it/LC_MESSAGES/messages.po locale/messages.pot

	if grep -nA1 '#-#-#-#-#' locale/*/LC_MESSAGES/messages.po; then echo -e "\nERROR: Conflicts encountered in PO files.\n"; exit 1; fi

# Compile translation files for use.
locale-compile:
	pybabel compile -d locale -l en --use-fuzzy
	pybabel compile -d locale -l de --use-fuzzy
	pybabel compile -d locale -l fr --use-fuzzy
	pybabel compile -d locale -l it --use-fuzzy
	pybabel compile -d locale -l es --use-fuzzy

# Process everything related to gettext translations.
locale: locale-update locale-compile

# Run the jinja2 templating engine to expand templates to HTML
# incorporating translations.
template: locale-compile
	$(PYTHON) ./template.py

it: template

current_dir = $(shell pwd)

run: all
	@[ "$(BROWSER)" ] || ( echo "You need to export the environment variable 'BROWSER' to run this."; exit 1 )
	$(RUN_BROWSER) $(current_dir)/en/index.html


# docker-all: Build using a docker image which contains all the needed packages.

docker: docker-all

docker-all:
	docker build -t gnunet-www-builder .
	# Importing via the shell like this is hacky, 
	# but after trying lots of other ways, this works most reliably...
	python3 -c 'import i18nfix'
	docker run --rm -v $$(pwd):/tmp/ --user $$(id -u):$$(id -g) gnunet-www-builder