annotate client/Makefile @ 963:e0825645f00e

merge
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 17 Oct 2018 15:22:38 +0200
parents bba166f0326e
children ea3a89a1813a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
141
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 # On OSX the PATH variable isn't exported unless "SHELL" is also set, see: http://stackoverflow.com/a/25506676
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
2 SHELL = /bin/bash
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
3 NODE_BINDIR = ./node_modules/.bin
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4 export PATH := $(NODE_BINDIR):$(PATH)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
6 # Where to write the files generated by this makefile.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
7 OUTPUT_DIR = src
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9 # Available locales for the app.
159
3d9341f6da4e feat: Locale of browser determines the default language
Thomas Junk <thomas.junk@intevation.de>
parents: 141
diff changeset
10 LOCALES = de_AT en_GB
141
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 # Name of the generated .po files for each available locale.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 LOCALE_FILES ?= $(patsubst %,$(OUTPUT_DIR)/locale/%/LC_MESSAGES/app.po,$(LOCALES))
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
15 GETTEXT_HTML_SOURCES = $(shell find $(OUTPUT_DIR) -name '*.vue' -o -name '*.html' 2> /dev/null)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16 GETTEXT_JS_SOURCES = $(shell find $(OUTPUT_DIR) -name '*.vue' -o -name '*.js')
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
17
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18 # Makefile Targets
459
bba166f0326e client: make Makefile more robust.
Bernhard Reiter <bernhard@intevation.de>
parents: 159
diff changeset
19 .PHONY: clean makemessages translations all
bba166f0326e client: make Makefile more robust.
Bernhard Reiter <bernhard@intevation.de>
parents: 159
diff changeset
20
bba166f0326e client: make Makefile more robust.
Bernhard Reiter <bernhard@intevation.de>
parents: 159
diff changeset
21 all:
bba166f0326e client: make Makefile more robust.
Bernhard Reiter <bernhard@intevation.de>
parents: 159
diff changeset
22 @echo choose a target from: clean makemessages translations
141
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
23
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
24 clean:
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
25 rm -f /tmp/template.pot $(OUTPUT_DIR)/translations.json
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
26
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
27 makemessages: /tmp/template.pot
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
28
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
29 translations: ./$(OUTPUT_DIR)/translations.json
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
30
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
31 # Create a main .pot template, then generate .po files for each available language.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
32 # Thanx to Systematic: https://github.com/Polyconseil/systematic/blob/866d5a/mk/main.mk#L167-L183
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
33 /tmp/template.pot: $(GETTEXT_HTML_SOURCES)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
34 # `dir` is a Makefile built-in expansion function which extracts the directory-part of `$@`.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
35 # `$@` is a Makefile automatic variable: the file name of the target of the rule.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
36 # => `mkdir -p /tmp/`
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
37 mkdir -p $(dir $@)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
38 which gettext-extract
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
39 # Extract gettext strings from templates files and create a POT dictionary template.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
40 gettext-extract --attribute v-translate --quiet --output $@ $(GETTEXT_HTML_SOURCES)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
41 # Extract gettext strings from JavaScript files.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
42 xgettext --language=JavaScript --keyword=npgettext:1c,2,3 \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
43 --from-code=utf-8 --join-existing --no-wrap \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
44 --package-name=$(shell node -e "console.log(require('./package.json').name);") \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
45 --package-version=$(shell node -e "console.log(require('./package.json').version);") \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
46 --output $@ $(GETTEXT_JS_SOURCES)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
47 # Generate .po files for each available language.
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
48 @for lang in $(LOCALES); do \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
49 export PO_FILE=$(OUTPUT_DIR)/locale/$$lang/LC_MESSAGES/app.po; \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
50 echo "msgmerge --update $$PO_FILE $@"; \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
51 mkdir -p $$(dirname $$PO_FILE); \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
52 [ -f $$PO_FILE ] && msgmerge --lang=$$lang --update $$PO_FILE $@ || msginit --no-translator --locale=$$lang --input=$@ --output-file=$$PO_FILE; \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
53 msgattrib --no-wrap --no-obsolete -o $$PO_FILE $$PO_FILE; \
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
54 done;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
55
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
56 $(OUTPUT_DIR)/translations.json: clean /tmp/template.pot
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
57 mkdir -p $(OUTPUT_DIR)
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
58 gettext-compile --output $@ $(LOCALE_FILES)