Skip to content

Commit

Permalink
chore: move scripts to makefile, except from_cn
Browse files Browse the repository at this point in the history
  • Loading branch information
rockleona committed Feb 21, 2024
1 parent 19039a0 commit c96d8ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
polib==1.1.1
googletrans==3.1.0a0
translate-toolkit==3.8.1
requests==2.31.0
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py
LANGUAGE := zh_TW
LC_MESSAGES := $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES
VENV := ~/.venvs/python-docs-i18n/
VENV_FOR_SCRIPT := ~/.venvs/python-docs-zhtw-script/
PYTHON := $(shell which python3)
MODE := autobuild-dev-html
BRANCH := $(or $(VERSION), $(shell git describe --contains --all HEAD))
Expand Down Expand Up @@ -75,6 +76,33 @@ $(VENV)/bin/sphinx-lint: $(VENV)/bin/activate
$(VENV)/bin/blurb: $(VENV)/bin/activate
. $(VENV)/bin/activate; python3 -m pip install blurb

$(VENV_FOR_SCRIPT)/bin/activate:
mkdir -p $(VENV_FOR_SCRIPT)
$(PYTHON) -m venv $(VENV_FOR_SCRIPT)
. $(VENV_FOR_SCRIPT)/bin/activate; python3 -m pip install -r .scripts/requirements.txt

.PHONY: summarize_progress
summarize_progress: $(VENV_FOR_SCRIPT)/bin/activate
cd .scripts && \
. $(VENV_FOR_SCRIPT)/bin/activate; \
python3 summarize_progress/main.py

.PHONY: google_translate
google_translate: $(VENV_FOR_SCRIPT)/bin/activate
if [ -z $(filter-out $@,$(MAKECMDGOALS)) ]; then \
echo "Please provide a file argument."; \
exit 1; \
fi

@$(eval __target=$(filter-out $@,$(MAKECMDGOALS)))
@$(eval __filepath=$(addprefix ../,$(__target)))
@$(eval __temp_po_file=tmp.po)

cd .scripts && \
. $(VENV_FOR_SCRIPT)/bin/activate; \
python3 google_translate/main.py $(__filepath) > $(__temp_po_file) ; pomerge -t $(__filepath) -i $(__temp_po_file) -o $(__filepath); rm "$(__temp_po_file)"
exit 0


.PHONY: upgrade_venv
upgrade_venv: $(VENV)/bin/activate ## Upgrade the venv that compiles the doc
Expand Down

0 comments on commit c96d8ea

Please sign in to comment.