File tree Expand file tree Collapse file tree 3 files changed +51
-14
lines changed
Expand file tree Collapse file tree 3 files changed +51
-14
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,11 @@ Translate all untranslated entries of the given .po file with Google Translate.
1010``` sh
1111.scripts/google_translate.sh library/csv.po
1212```
13+
14+ ## From zh_CN Translation
15+
16+ If a specific doc has been translated into Simplified Chinese (zh_CN) and you'd like to adopt it as a base, you can insert the command:
17+
18+ ``` sh
19+ .scripts/from_cn.sh library/csv.po
20+ ```
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ cd .scripts
3+ source utils/install_poetry.sh
4+
5+ # check if OpenCC is installed
6+ if [[ ! -x " ` which opencc 2> /dev/null` " ]]
7+ then
8+ echo " You do not have OpenCC installed. Please install it first."
9+ echo " Instruction: https://github.com/BYVoid/OpenCC/wiki/Download"
10+ exit 1
11+ fi
12+
13+ # clone pydoc zh_CN repo and pull from remote
14+ CN_REPO=.python-docs-zh-cn
15+ if [[ ! -d $CN_REPO ]]
16+ then
17+ read -p " You do not have a clone of zh_CN repo. Clone now? (y/N)" choice
18+ case " $choice " in
19+ y|Y ) git clone --depth 1 --no-single-branch https://github.com/python/python-docs-zh-cn $CN_REPO ;;
20+ n|N|* ) echo " Aborted" ; exit 1 ;;
21+ esac
22+ fi
23+ git -C $CN_REPO checkout 3.10 # the current latest version of CN repo
24+ git -C $CN_REPO pull
25+
26+
27+ # convert zh_CN po content and merge into zh_TW po
28+ TARGET=$1
29+ CN_PATH=$CN_REPO /$TARGET
30+ TW_PATH=../$TARGET
31+
32+ poetry install -q
33+ poetry run bash -c "
34+ opencc -i $CN_PATH -c s2twp.json -o /tmp/tmp.po
35+ pofilter --nonotes --excludefilter unchanged --excludefilter untranslated /tmp/tmp.po | msgattrib --set-fuzzy -o /tmp/tmp.po
36+ pomerge -t $CN_PATH -i /tmp/tmp.po -o /tmp/tmp.po
37+
38+ pofilter --nonotes --excludefilter untranslated $TW_PATH /tmp/tmp2.po
39+ pomerge -t /tmp/tmp.po -i /tmp/tmp2.po -o /tmp/tmp3.po
40+ msgcat --lang zh_TW /tmp/tmp3.po -o $TW_PATH
41+ "
42+
43+ rm /tmp/tmp.po /tmp/tmp2.po /tmp/tmp3.po
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments