themactep.com

A home of miscellaneous projects by Paul Philippov.

Notes

How to restore and translate Chinese comments in sources on a Unicode system

Use this script:

#!/bin/sh
# cn2en.sh
# Paul Philippov, themactep.com
# 20200926

infile=$1
cnfile="${infile%.*}.cn.${infile##*.}"
enfile="${infile%.*}.en.${infile##*.}"

cat "$infile" | iconv -f gb2312 -t utf8 - > "$cnfile"
trans -brief zh:en <  "$cnfile" > "$enfile"

You will need translate-shell v.0.9.7 or higher.