一个简单的 Swift String
扩展,用于将直撇号和引号转换为印刷上正确的弯引号。
此包在 String
上提供一个 .withSmartQuotes
属性,默认情况下进行英文转换。
对于其他本地化,可以为 .withSmartQuotes(locale: Locale?)
提供一个区域设置 (locale)。目前仅实现了 de
、fi
和 sv
。我欢迎对其他本地化的贡献!
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")
)
# Cartfile
github "hallee/swift-smart-quotes" ~> 0.0.1
# Podfile
pod 'SmartQuotes'
dependencies: [
.package(url: "https://github.com/hallee/swift-smart-quotes", from: "0.0.1")
],
targets: [
.target(name: "YourTarget", dependencies: ["SmartQuotes"])
]