OpenCC Swift wrapper
This package requires the Home Brew build of OpenCC.
To install Home Brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This package requires OpenCC installed.
git clone https://github.com/BYVoid/OpenCC.git
cd OpenCC
make
sudo make install
Add this project as a dependency in your Package.swift file.
.Package(url:"https://github.com/shiningdracon/OpenCC-swift", majorVersion: 1)
import OpenCC
let openccS2T = OpenCC(configFile: "s2t.json")
let openccT2S = OpenCC(configFile: "t2s.json")
func ChineseConvertSimplified2Traditional(_ s: String) -> String {
if let t = openccS2T.convert(s) {
return t
} else {
return ""
}
}
func ChineseConvertTraditional2Simplified(_ t: String) -> String {
if let s = openccT2S.convert(t) {
return s
} else {
return ""
}
}