From 6973c37386b3621c19043e924b9016a8be3e9111 Mon Sep 17 00:00:00 2001 From: Roman Petrenko Date: Wed, 18 May 2016 17:09:03 +0300 Subject: [PATCH 1/2] #48: Support for localization of Cancel and Delete buttons --- PasscodeLock/PasscodeLockViewController.swift | 3 +++ PasscodeLock/en.lproj/PasscodeLock.strings | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index 095f10f2..bfe6e701 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -84,6 +84,9 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg super.viewDidLoad() updatePasscodeView() + + cancelButton?.setTitle(localizedStringFor("PasscodeLockCancelButtonTitle", comment: "Cancel Button Title"), forState: .Normal) + deleteSignButton?.setTitle(localizedStringFor("PasscodeLockDeleteButtonTitle", comment: "Delete Button Title"), forState: .Normal) deleteSignButton?.enabled = false setupEvents() diff --git a/PasscodeLock/en.lproj/PasscodeLock.strings b/PasscodeLock/en.lproj/PasscodeLock.strings index f71ef86c..8ae4e796 100755 --- a/PasscodeLock/en.lproj/PasscodeLock.strings +++ b/PasscodeLock/en.lproj/PasscodeLock.strings @@ -26,6 +26,12 @@ "PasscodeLockMismatchTitle" = "Try again"; "PasscodeLockMismatchDescription" = "Passcodes didn\'t match."; +/* Cancel Button Title */ +"PasscodeLockCancelButtonTitle" = "Cancel"; + +/* Delete Button Title */ +"PasscodeLockDeleteButtonTitle" = "Delete"; + /* Touch ID Reason */ "PasscodeLockTouchIDReason" = "Authentication required to proceed"; From 925334fbc0cc349685c1481f10c8462285243146 Mon Sep 17 00:00:00 2001 From: Roman Petrenko Date: Wed, 18 May 2016 17:17:14 +0300 Subject: [PATCH 2/2] #48: Take localized string from default bundle if user's bundle misses it --- PasscodeLock/Functions.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PasscodeLock/Functions.swift b/PasscodeLock/Functions.swift index adb03903..df0b56bb 100644 --- a/PasscodeLock/Functions.swift +++ b/PasscodeLock/Functions.swift @@ -11,9 +11,9 @@ import Foundation func localizedStringFor(key: String, comment: String) -> String { let name = "PasscodeLock" - let bundle = bundleForResource(name, ofType: "strings") + let defaultString = NSLocalizedString(key, tableName: name, bundle: NSBundle(forClass: PasscodeLock.self), comment: comment) - return NSLocalizedString(key, tableName: name, bundle: bundle, comment: comment) + return NSLocalizedString(key, value: defaultString, tableName: name, bundle: NSBundle.mainBundle(), comment: comment) } func bundleForResource(name: String, ofType type: String) -> NSBundle {