Skip to content

Commit

Permalink
Localization improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ysoftware committed May 17, 2017
1 parent 9babe5b commit 52e81bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
22 changes: 11 additions & 11 deletions PasscodeLock/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

import Foundation

func localizedStringFor(_ key: String, comment: String) -> String {
func localizedStringFor(key: String, comment: String) -> String {

let name = "PasscodeLock"
let bundle = bundleForResource(name, ofType: "strings")
return NSLocalizedString(key, tableName: name, bundle: bundle, comment: comment)
let defaultString = NSLocalizedString(key, tableName: name, bundle: NSBundle(forClass: PasscodeLock.self), comment: comment)

return NSLocalizedString(key, value: defaultString, tableName: name, bundle: NSBundle.mainBundle(), comment: comment)
}

func bundleForResource(_ name: String, ofType type: String) -> Bundle {
if(Bundle.main.path(forResource: name, ofType: type) != nil) {
return Bundle.main
func bundleForResource(name: String, ofType type: String) -> NSBundle {

if(NSBundle.mainBundle().pathForResource(name, ofType: type) != nil) {
return NSBundle.mainBundle()
}
return Bundle(for: PasscodeLock.self)

return NSBundle(forClass: PasscodeLock.self)
}
3 changes: 3 additions & 0 deletions PasscodeLock/PasscodeLockViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegat

updatePasscodeView()
deleteSignButton?.isEnabled = false

cancelButton?.setTitle(localizedStringFor("PasscodeLockCancelButtonTitle", comment: "Cancel Button Title"), forState: .Normal)
deleteSignButton?.setTitle(localizedStringFor("PasscodeLockDeleteButtonTitle", comment: "Delete Button Title"), forState: .Normal)

setupEvents()
}
Expand Down
7 changes: 6 additions & 1 deletion PasscodeLock/en.lproj/PasscodeLock.strings
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
"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";

/* Touch ID Fallback Button */
"PasscodeLockTouchIDButton" = "Enter Passcode";
"PasscodeLockTouchIDButton" = "Enter Passcode";

0 comments on commit 52e81bd

Please sign in to comment.