Skip to content

Commit

Permalink
Replace NSLocalizedString() with Localizable following br1sk#25
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanhuang13 committed Jul 19, 2018
1 parent 9713063 commit 7229013
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Brisk iOS/App/StatusDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ extension StatusDisplay where Self: UIViewController {
SVProgressHUD.showSuccess(withStatus: message)
}

func showError(title: String? = NSLocalizedString("Global.Error", comment: ""),
func showError(title: String? = Localizable.Global.error.localized,
message: String,
dismissButtonTitle: String? = NSLocalizedString("Global.Dismiss", comment: ""),
dismissButtonTitle: String? = Localizable.Global.dismiss.localized,
completion: (() -> Void)? = nil) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: dismissButtonTitle, style: .cancel, handler: nil))
Expand Down
5 changes: 5 additions & 0 deletions Brisk iOS/Model/Localizable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ enum Localizable {
case cancel = "Global.Cancel"
}

enum QuickAction: Localize, LocalizeRepresentable {
case newRadar = "QuickAction.NewRadar"
case duplicateRadar = "QuickAction.DuplicateRadar"
}

enum Login {
enum Error: Localize, LocalizeRepresentable {
case invalidEmail = "LoginError.InvalidEmail"
Expand Down
4 changes: 2 additions & 2 deletions Brisk iOS/Model/QuickAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public extension QuickAction {
let icon = UIApplicationShortcutIcon(templateImageName: "Compose")

return UIApplicationShortcutItem(type: "new-radar",
localizedTitle: NSLocalizedString("QuickAction.NewRadar", comment: ""),
localizedTitle: Localizable.QuickAction.newRadar.localized,
localizedSubtitle: nil,
icon: icon)
}
Expand All @@ -22,7 +22,7 @@ public extension QuickAction {
let icon = UIApplicationShortcutIcon(templateImageName: "Duplicate")

return UIApplicationShortcutItem(type: "duplicate-radar",
localizedTitle: NSLocalizedString("QuickAction.DuplicateRadar", comment: ""),
localizedTitle: Localizable.QuickAction.duplicateRadar.localized,
localizedSubtitle: nil,
icon: icon)
}
Expand Down
4 changes: 2 additions & 2 deletions Brisk iOS/Radar/SubmitRadarDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ final class SubmitRadarDelegate: APIDelegate {
func didPostToAppleRadar() {
display.hideLoading()
let delay = 3.0
display.showSuccess(message: NSLocalizedString("Radar.Post.Success", comment: ""), autoDismissAfter: delay)
display.showSuccess(message: Localizable.Radar.Post.success.localized, autoDismissAfter: delay)
finishHandler(true)
}

func didPostToOpenRadar() {
display.hideLoading()
display.showSuccess(message: NSLocalizedString("Radar.Post.Success", comment: ""), autoDismissAfter: 3.0)
display.showSuccess(message: Localizable.Radar.Post.success.localized, autoDismissAfter: 3.0)
finishHandler(false)
}

Expand Down
4 changes: 2 additions & 2 deletions Brisk iOS/Radar/TwoFactorAuthentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ final class TwoFactorAuthentication: TwoFactorAuthenticationHandler {
}

func askForCode(completion: @escaping (String) -> Void) {
let alert = UIAlertController(title: NSLocalizedString("Radar.TwoFactorAuth.Title", comment: ""), message: NSLocalizedString("Radar.TwoFactorAuth.Message", comment: ""), preferredStyle: .alert)
let alert = UIAlertController(title: Localizable.Radar.TwoFactor.title.localized, message: Localizable.Radar.TwoFactor.message.localized, preferredStyle: .alert)
alert.addTextField { (field) in
field.keyboardType = .numberPad
let bodyDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
field.font = UIFont(descriptor: bodyDescriptor, size: bodyDescriptor.pointSize)
field.autocorrectionType = .no
field.enablesReturnKeyAutomatically = true
}
alert.addAction(UIAlertAction(title: NSLocalizedString("Radar.TwoFactorAuth.Submit", comment: ""), style: .default, handler: { _ in
alert.addAction(UIAlertAction(title: Localizable.Radar.TwoFactor.submit.localized, style: .default, handler: { _ in
guard let field = alert.textFields?.first else { preconditionFailure() }
guard let text = field.text, text.isNotEmpty else {
alert.dismiss(animated: true) {
Expand Down

0 comments on commit 7229013

Please sign in to comment.