@@ -41,6 +41,7 @@ SPHINX_CONF := $(CPYTHON_CLONE)/Doc/conf.py
4141LANGUAGE := zh_TW
4242LC_MESSAGES := $(CPYTHON_CLONE ) /Doc/locales/$(LANGUAGE ) /LC_MESSAGES
4343VENV := ~/.venvs/python-docs-i18n/
44+ VENV_FOR_SCRIPT := ~/.venvs/python-docs-zhtw-script/
4445PYTHON := $(shell which python3)
4546MODE := autobuild-dev-html
4647BRANCH := $(or $(VERSION ) , $(shell git describe --contains --all HEAD) )
@@ -75,6 +76,33 @@ $(VENV)/bin/sphinx-lint: $(VENV)/bin/activate
7576$(VENV ) /bin/blurb : $(VENV ) /bin/activate
7677 . $(VENV ) /bin/activate; python3 -m pip install blurb
7778
79+ $(VENV_FOR_SCRIPT ) /bin/activate :
80+ mkdir -p $(VENV_FOR_SCRIPT )
81+ $(PYTHON ) -m venv $(VENV_FOR_SCRIPT )
82+ . $(VENV_FOR_SCRIPT ) /bin/activate; python3 -m pip install -r .scripts/requirements.txt
83+
84+ .PHONY : summarize_progress
85+ summarize_progress : $(VENV_FOR_SCRIPT ) /bin/activate
86+ cd .scripts && \
87+ . $(VENV_FOR_SCRIPT ) /bin/activate; \
88+ python3 summarize_progress/main.py
89+
90+ .PHONY : google_translate
91+ google_translate : $(VENV_FOR_SCRIPT ) /bin/activate
92+ if [ -z $( filter-out $@ ,$( MAKECMDGOALS) ) ]; then \
93+ echo " Please provide a file argument." ; \
94+ exit 1; \
95+ fi
96+
97+ @$(eval __target=$(filter-out $@,$(MAKECMDGOALS)))
98+ @$(eval __filepath=$(addprefix ../,$(__target)))
99+ @$(eval __temp_po_file=tmp.po)
100+
101+ cd .scripts && \
102+ . $(VENV_FOR_SCRIPT)/bin/activate; \
103+ python3 google_translate/main.py $(__filepath) > $(__temp_po_file) ; pomerge -t $(__filepath) -i $(__temp_po_file) -o $(__filepath); rm "$(__temp_po_file)"
104+ exit 0
105+
78106
79107.PHONY : upgrade_venv
80108upgrade_venv : $(VENV ) /bin/activate # # Upgrade the venv that compiles the doc
0 commit comments