WWJavaScriptContext+ChineseConvert

main

Use JavaScript to convert traditional and simplified Chinese text.
William-Weng/WWJavaScriptContext_ChineseConvert

WWJavaScriptContext+ChineseConvert

Swift-5.6 iOS-14.0 Tag Swift Package Manager-SUCCESS LICENSE

dependencies: [
    .package(url: "https://github.com/William-Weng/WWJavaScriptContext_ChineseConvert.git", .upToNextMajor(from: "1.1.0"))
]

Function - 可用函式

函式 功能
convert(_:to:) 繁體 <=> 簡體

Example

import UIKit
import WWJavaScriptContext
import WWJavaScriptContext_ChineseConvert

final class ViewController: UIViewController {

    @IBOutlet weak var myLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    /// 簡體 => 正體
    /// - Parameter sender: UIBarButtonItem
    @IBAction func convert_zh_TW(_ sender: UIBarButtonItem) {
        
        let traditionalChinese = WWJavaScriptContext.ChineseConvert.shared.convert(myLabel.text, to: .tw)
        myLabel.text = traditionalChinese
    }
    
    /// 繁體 => 簡體
    /// - Parameter sender: UIBarButtonItem
    @IBAction func convert_zh_CN(_ sender: UIBarButtonItem) {
        
         let simplifiedChinese = WWJavaScriptContext.ChineseConvert.shared.convert(myLabel.text, to: .cn)
         myLabel.text = simplifiedChinese
    }
}

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 16:38:26 GMT-0900 (Hawaii-Aleutian Daylight Time)