forked from project-trans/transfeminine-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencc.sh
executable file
·37 lines (31 loc) · 798 Bytes
/
opencc.sh
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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
function cc() {
local original="$1"
local language="$2"
local config="$3"
local input="content/$original"
local output="content.$language/$original"
mkdir -p "$(dirname "$output")"
opencc \
--config "$config" \
--input "$input" \
--output "$output"
}
files=$(
cd content || exit
find . -type f -name '*.md'
)
for file in $files; do
cc "$file" "zh-tw" "$SCRIPT_DIR/s2twp.json"
cc "$file" "zh-hk" "s2hk"
done
opencc \
--config "$SCRIPT_DIR/s2twp.json" \
--input "data/abbreviation.zh-cn.yaml" \
--output "data/abbreviation.zh-tw.yaml"
opencc \
--config "s2hk" \
--input "data/abbreviation.zh-cn.yaml" \
--output "data/abbreviation.zh-hk.yaml"