智能引号 (SmartQuotes)

一个简单的 Swift String 扩展,用于将直撇号和引号转换为印刷上正确的弯引号。

此包在 String 上提供一个 .withSmartQuotes 属性,默认情况下进行英文转换。

对于其他本地化,可以为 .withSmartQuotes(locale: Locale?) 提供一个区域设置 (locale)。目前仅实现了 defisv。我欢迎对其他本地化的贡献!

用法

import SmartQuotes

"\"Crime peaked in the '90s\"".withSmartQuotes   // “Crime peaked in the ’90s”

"\"Crime peaked in the '90s\"".withSmartQuotes(  // „Crime peaked in the ‘90s“
    Locale(identifier: "de")
)

安装

Carthage

# Cartfile
github "hallee/swift-smart-quotes" ~> 0.0.1

CocoaPods

# Podfile
pod 'SmartQuotes'

SwiftPM

dependencies: [
    .package(url: "https://github.com/hallee/swift-smart-quotes", from: "0.0.1")
],
targets: [
    .target(name: "YourTarget", dependencies: ["SmartQuotes"])
]

待办事项 (TODO)