Files
GitHawk/Classes/Systems/Signature.swift
Bas Broek 377161aed0 Fix Int format crash + unify String localization (#1273)
* 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`).
2017-12-17 16:10:57 -05:00

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>"
}
}