forked from andrey-yantsen/boterator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
38 lines (28 loc) · 1.62 KB
/
Makefile
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
deploy:
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -A $(DEPLOY_TO) "cd ~/boterator && git fetch origin && git reset --hard origin/master && source ../.bashrc && pip3 install -r requirements.txt && make compile_messages"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -A $(DEPLOY_TO) "touch ~/restart.txt"
DOMAIN = boterator
BASE_DIR = locales
compile_messages:
@pybabel compile --domain=$(DOMAIN) --directory=$(BASE_DIR)
LANG=en
LOCALE_DIR = $(BASE_DIR)/$(LANG)/LC_MESSAGES
POT_FILE = $(BASE_DIR)/$(DOMAIN).pot
PO_FILE = $(LOCALE_DIR)/$(DOMAIN).po
BABEL_CONFIG = $(BASE_DIR)/babel.cfg
collect_messages:
@pybabel extract ./ --project=boterator --version=$$(git rev-parse --short HEAD) --output=$(POT_FILE) \
--charset=UTF-8 --sort-by-file --mapping=$(BABEL_CONFIG)
build_translation: collect_messages
@test -f "$(PO_FILE)" \
&& pybabel update --domain=$(DOMAIN) --input-file=$(POT_FILE) --output-dir=$(BASE_DIR) --locale=$(LANG) --no-wrap \
|| pybabel init --input-file=$(POT_FILE) --output-dir=$(BASE_DIR) --domain=$(DOMAIN) --locale=$(LANG) --no-wrap
upload_loco: collect_messages
@curl -s -XPOST -H 'Content-type: text/x-gettext-translation' -H 'Authorization: Loco $(LOCO_KEY)' \
--data-binary @locales/boterator.pot https://localise.biz/api/import/pot > /dev/null
download_loco:
@curl -s -H 'Authorization: Loco $(LOCO_KEY)' https://localise.biz/api/export/archive/po.zip -o loco.zip
@unzip loco.zip >/dev/null && rm loco.zip
@rsync -r boterator-po-archive/locales/ ./locales/ && rm -rf ./locales/en
@rm -rf boterator-po-archive
compile_messages_loco: download_loco compile_messages