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