/SwiftyOpenCC

Swift port of OpenCC for conversion between Traditional and Simplified Chinese

Primary LanguageSwiftMIT LicenseMIT

Swifty Open Chinese Convert

Github CI Status platforms codebeat badge

Swift port of Open Chinese Convert

Requirements

  • macOS 10.10+ / iOS 8.0+ / tvOS 9.0+ / watchOS 2.0+
  • Swift 5.0

Usage

Quick Start

import OpenCC

let str = "鼠标里面的硅二极管坏了,导致光标分辨率降低。"
let converter = try! ChineseConverter(option: [.traditionalize, .twStandard, .twIdiom])
converter.convert(str)
// 滑鼠裡面的矽二極體壞了,導致游標解析度降低。

Documentation

Github Pages (100% Documented)

Build you own

  1. Install requirements

    brew install cmake doxygen
  2. Checkout new version, like v1.1.7

  3. Make OpenCC

     cd OpenCC
     make
  4. Copy all ./OpenCC/build/perf/data/*.ocd2 files to ./Sources/OpenCC/Dictionary/

    cd ..
    cp ./OpenCC/build/perf/data/*.ocd2 ./Sources/OpenCC/Dictionary/
  5. Copy ./OpenCC/build/perf/src/opencc_config.h to ./OpenCC/src/opencc_config.h

    cp ./OpenCC/build/perf/src/opencc_config.h ./OpenCC/src/opencc_config.h
  6. Run test in Xcode: Cmd+U

License

SwiftyOpenCC is available under the MIT license. See the LICENSE file.