mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-03 19:43:10 +08:00
* Use %d over %zi to prevent a possible crash * Clean up / unify localization behavior Before, we were doing double localization (Feeding a `LocalizedString` into a `.localizedStringWithFormat`).
33 lines
855 B
Swift
33 lines
855 B
Swift
//
|
|
// Signature.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 9/12/17.
|
|
// Copyright © 2017 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
enum Signature {
|
|
|
|
private static let key = "com.freetime.Signature.enabled"
|
|
|
|
static var enabled: Bool {
|
|
get {
|
|
// using the object API allows us to return true for init state
|
|
return UserDefaults.standard.object(forKey: key) as? Bool ?? true
|
|
}
|
|
set {
|
|
UserDefaults.standard.set(newValue, forKey: key)
|
|
}
|
|
}
|
|
|
|
static func signed(text: String) -> String {
|
|
guard enabled else { return text }
|
|
let format = NSLocalizedString("Sent with %@", comment: "")
|
|
let signature = String(format: format, "<a href=\"http://githawk.com\">GitHawk</a>")
|
|
return text + "\n\n<sub>\(signature)</sub>"
|
|
}
|
|
|
|
}
|