Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
moved all NSLocalizedStrings to the language file and replaced the names in the swift code with slugs.
  • Loading branch information
SerhiiShovkoplias committed Jun 24, 2020
1 parent 0499c10 commit b907831
Show file tree
Hide file tree
Showing 38 changed files with 269 additions and 294 deletions.
12 changes: 12 additions & 0 deletions MobileWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
3708D756247FF81900807D72 /* SettingsParentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3708D755247FF81900807D72 /* SettingsParentViewController.swift */; };
3708D757247FF81900807D72 /* SettingsParentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3708D755247FF81900807D72 /* SettingsParentViewController.swift */; };
3708D758247FF81900807D72 /* SettingsParentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3708D755247FF81900807D72 /* SettingsParentViewController.swift */; };
37098043249CD48A0004ED2E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 37098045249CD48A0004ED2E /* Localizable.strings */; };
371189732488FF11004D0CE3 /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 371189722488FF11004D0CE3 /* CloudKit.framework */; };
371A0818247290C000F97713 /* TransitionLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371A0817247290C000F97713 /* TransitionLabel.swift */; };
371A0819247290C000F97713 /* TransitionLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 371A0817247290C000F97713 /* TransitionLabel.swift */; };
Expand Down Expand Up @@ -699,6 +700,7 @@
3708D749247FCF2300807D72 /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
3708D751247FF7D000807D72 /* BackupWalletSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackupWalletSettingsViewController.swift; sourceTree = "<group>"; };
3708D755247FF81900807D72 /* SettingsParentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsParentViewController.swift; sourceTree = "<group>"; };
37098044249CD48A0004ED2E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
371189722488FF11004D0CE3 /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
371A0817247290C000F97713 /* TransitionLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransitionLabel.swift; sourceTree = "<group>"; };
373CCDBC2490B66E00D0A2C9 /* CircularProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1209,6 +1211,7 @@
37B4449C24890F3000592D92 /* Backup */,
00262EB2236F022000A6C8A0 /* Common */,
00262EB7236F35B200A6C8A0 /* Models */,
37098045249CD48A0004ED2E /* Localizable.strings */,
);
path = MobileWallet;
sourceTree = "<group>";
Expand Down Expand Up @@ -1712,6 +1715,7 @@
BF191A2023E5AFA200D33C85 /* img_1.png in Resources */,
BF0A77B52420CF1200861A3E /* NotificationAnimation.json in Resources */,
BFE1FC0223E229FF00BA5EEC /* CheckMark.json in Resources */,
37098043249CD48A0004ED2E /* Localizable.strings in Resources */,
BF191A0D23E5A96700D33C85 /* EmojiWheel.json in Resources */,
BFF1EDA32408225900CC9EF6 /* sendingTariAnimation.json in Resources */,
BF191A1A23E5AFA200D33C85 /* img_2.png in Resources */,
Expand Down Expand Up @@ -2443,6 +2447,14 @@
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
37098045249CD48A0004ED2E /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
37098044249CD48A0004ED2E /* en */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
15 changes: 6 additions & 9 deletions MobileWallet/Backup/ICloudBackup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,23 @@ enum ICloudBackupWalletError: Error {
case dbFileNotFound
case iCloudContainerNotFound
case unableCreateBackupFolder
case privateKeyError
}

extension ICloudBackupWalletError: LocalizedError {
public var errorDescription: String? {
switch self {
case .failedToCreateZip:
return NSLocalizedString("Failed to create wallet backup archive", comment: "backup archive error description")
return NSLocalizedString("iCloud_backup.error.zip", comment: "iCloudBackup error")
case .noICloudBackupExists:
return NSLocalizedString("You don't have any wallets backed up with iCloud", comment: "'No any wallet backup' error description")
return NSLocalizedString("iCloud_backup.error.no_backup_exists", comment: "iCloudBackup error")
case .unarchiveError:
return NSLocalizedString("Unable to unarchive wallet from iCloud backup", comment: "unarchive wallet error description")
return NSLocalizedString("iCloud_backup.error.unzip", comment: "iCloudBackup error")
case .dbFileNotFound:
return NSLocalizedString("Unable to create wallet backup. File not found", comment: "sqlite file not found error description")
return NSLocalizedString("iCloud_backup.error.db_not_found", comment: "iCloudBackup error")
case .iCloudContainerNotFound:
return NSLocalizedString("Can't connect to iCloud Drive services. Make sure that you are signed in with your Apple ID on this device and that iCloud is enabled.", comment: "iCloud container not found error description")
return NSLocalizedString("iCloud_backup.error.container_not_found", comment: "iCloudBackup error")
case .unableCreateBackupFolder:
return NSLocalizedString("Unable to create backup folder", comment: "Unable to create backup folder error description")
case .privateKeyError:
return NSLocalizedString("Unable to restore wallet. Private key error", comment: "Unable to restore wallet private key error descroption")
return NSLocalizedString("iCloud_backup.error.unable_create_backup_folder", comment: "iCloudBackup error")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ReminderNotifications {

static let titleString = String(
format: NSLocalizedString(
"You've been sent %@!",
"scheduled_reminder.title.with_param",
comment: "Local reminder notifications"
),
TariSettings.shared.network.currencyDisplayTicker
Expand All @@ -64,15 +64,15 @@ class ReminderNotifications {
ScheduledReminder(
identifier: "scheduled-reminders-recipient-1",
title: ReminderNotifications.titleString,
body: NSLocalizedString("Open Tari Aurora", comment: "Local reminder notifications"),
body: NSLocalizedString("scheduled_reminder.body.short", comment: "Local reminder notifications"),
deliverAfter: TariSettings.shared.environment == .production ? 60 * 60 * 24 : 60 * 60 * 2 //24h for prod and 2h for debug/testflight
),
ScheduledReminder(
identifier: "scheduled-reminders-recipient-2",
title: ReminderNotifications.titleString,
body: String(
format: NSLocalizedString(
"Someone sent you %@! Open Tari Aurora to receive it now or it will be returned to the sender.",
"scheduled_reminder.body.long.with_param",
comment: "Local reminder notifications"
),
TariSettings.shared.network.currencyDisplayTicker
Expand Down
2 changes: 1 addition & 1 deletion MobileWallet/Common/CopyableLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension CopyableLabel {
greenView.backgroundColor = Theme.shared.colors.transactionCellValuePositiveText?.withAlphaComponent(0.12)

let copiedLabel = UILabel()
copiedLabel.text = NSLocalizedString("COPIED", comment: "Emoji ID copied")
copiedLabel.text = NSLocalizedString("emoji.copied", comment: "Emoji view")
copiedLabel.font = Theme.shared.fonts.copiedLabelFont
copiedLabel.textColor = Theme.shared.colors.textButtonSecondary

Expand Down
10 changes: 5 additions & 5 deletions MobileWallet/Common/DeepLinkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class DeeplinkNavigator {
homeVC.onSend(pubKey: pubKey, deepLinkParams: params)
} catch {
UserFeedback.shared.error(
title: NSLocalizedString("Invalid link found", comment: "Deep link error"),
description: NSLocalizedString("Could not get emoji ID from link", comment: "Deep link error"),
title: NSLocalizedString("deep_link.error.title", comment: "Deep link error"),
description: NSLocalizedString("deep_link.error.emoji_from_link", comment: "Deep link error"),
error: error
)
}
Expand All @@ -140,7 +140,7 @@ class ShortcutParser {
let showQRShortcutItem = UIApplicationShortcutItem(
type: ShortcutKey.showQR.rawValue,
localizedTitle: NSLocalizedString(
"Show my QR",
"shortcut.show_my_qr",
comment: "Home screen shortcut"
),
localizedSubtitle: nil,
Expand All @@ -152,8 +152,8 @@ class ShortcutParser {
type: ShortcutKey.send.rawValue,
localizedTitle: String(
format: NSLocalizedString(
"Send %@",
comment: "Home screen shortcut"
"common.send.with_param",
comment: "Common"
),
TariSettings.shared.network.currencyDisplayTicker
),
Expand Down
4 changes: 2 additions & 2 deletions MobileWallet/Common/Extensions/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ extension Date {
*/
func relativeDayFromToday() -> String? {
if Calendar.current.isDateInToday(self) {
return NSLocalizedString("Today", comment: "Transaction list section heading")
return NSLocalizedString("tx_list.today", comment: "Transaction list section heading")
} else if Calendar.current.isDateInYesterday(self) {
return NSLocalizedString("Yesterday", comment: "Transaction list section heading")
return NSLocalizedString("tx_list.yesterday", comment: "Transaction list section heading")
} else {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = DateFormatter.dateFormat(fromTemplate: "MMM d, yyyy", options: 0, locale: .current)
Expand Down
20 changes: 10 additions & 10 deletions MobileWallet/Common/Extensions/LAContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ extension LAContext {

var rawValue: String {
switch self {
case .logIn: return NSLocalizedString("Log in to your account", comment: "Authentication")
case .userVerification: return NSLocalizedString("User Verification", comment: "Authentication")
case .logIn: return NSLocalizedString("authentication.reason.login", comment: "Authentication")
case .userVerification: return NSLocalizedString("authentication.reason.user_verification", comment: "Authentication")
}
}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ extension LAContext {
if success {
onSuccess()
} else {
let localizedReason = error?.localizedDescription ?? NSLocalizedString("Failed to authenticate", comment: "Failed Face/Touch ID alert")
let localizedReason = error?.localizedDescription ?? NSLocalizedString("authentication.fail.description", comment: "Authentication")
TariLogger.error("Biometrics auth failed", error: error)
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
Expand All @@ -104,16 +104,16 @@ extension LAContext {
}
}
case .none:
let alert = UIAlertController(title: NSLocalizedString("Authentication Error", comment: "No biometric or passcode") ,
message: NSLocalizedString("Tari Aurora was not able to authenticate you. Do you still want to proceed?", comment: "No biometric or passcode"),
let alert = UIAlertController(title: NSLocalizedString("authentication.error.title", comment: "Authentication") ,
message: NSLocalizedString("authentication.error.description", comment: "Authentication"),
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("Try again", comment: "Try again button"),
alert.addAction(UIAlertAction(title: NSLocalizedString("authentication.try_again", comment: "Authentication"),
style: .cancel,
handler: { [weak self] _ in
self?.authenticateUser(onSuccess: onSuccess)
}))

alert.addAction(UIAlertAction(title: NSLocalizedString("Proceed", comment: "Proceed button"), style: .default, handler: { _ in
alert.addAction(UIAlertAction(title: NSLocalizedString("authentication.proceed", comment: "Authentication"), style: .default, handler: { _ in
onSuccess()
}))

Expand All @@ -124,13 +124,13 @@ extension LAContext {
}

private func authenticationFailedAlertOptions(reason: String, onSuccess: @escaping () -> Void) {
let alert = UIAlertController(title: NSLocalizedString("Authentication failed", comment: "Auth failed"), message: reason, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("Try again", comment: "Try again button"), style: .default, handler: { [weak self] _ in
let alert = UIAlertController(title: NSLocalizedString("authentication.fail.title", comment: "Authentication"), message: reason, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("Try again", comment: "Authentication"), style: .default, handler: { [weak self] _ in
guard let self = self else { return }
self.authenticateUser(onSuccess: onSuccess)
}))

alert.addAction(UIAlertAction(title: NSLocalizedString("Open settings", comment: "Open settings button"), style: .default, handler: { [weak self] _ in
alert.addAction(UIAlertAction(title: NSLocalizedString("authentication.action.open_settings", comment: "Authentication"), style: .default, handler: { [weak self] _ in
guard let self = self else { return }
self.openAppSettings()
}))
Expand Down
2 changes: 1 addition & 1 deletion MobileWallet/Common/UserFeedback/FeedbackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class FeedbackView: UIView {
closeButton.setVariation(.secondary)
closeButton.translatesAutoresizingMaskIntoConstraints = false
addSubview(closeButton)
closeButton.setTitle(NSLocalizedString("Close", comment: "User feedback bottom float"), for: .normal)
closeButton.setTitle(NSLocalizedString("feedback_view.close", comment: "Feedback view"), for: .normal)
closeButton.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
closeButton.addTarget(self, action: #selector(onCloseButtonPressed), for: .touchUpInside)
}
Expand Down
10 changes: 5 additions & 5 deletions MobileWallet/Common/UserFeedback/UserFeedback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,21 @@ class UserFeedback {
imageTop: imageTop,
title: String(
format: NSLocalizedString(
"Spend %@ on exclusive stuff",
"store_modal.title.with_param",
comment: "Store modal"
),
TariSettings.shared.network.currencyDisplayTicker
),
boldedTitle: NSLocalizedString("exclusive stuff", comment: "Store modal"),
boldedTitle: NSLocalizedString("store_modal.bold_title", comment: "Store modal"),
description: String(
format: NSLocalizedString(
"Check out The TTL Store to spend your “hard-earned” %@ on exclusive, one-of-a-kind stuff produced by the team at Tari Labs. Enjoy!",
"store_modal.description",
comment: "Store modal"
),
TariSettings.shared.network.currencyDisplayTicker
),
cancelTitle: NSLocalizedString("I’ll check it out later", comment: "Store modal"),
actionTitle: NSLocalizedString("Visit The TTL Store", comment: "Store modal"),
cancelTitle: NSLocalizedString("store_modal.cancel", comment: "Store modal"),
actionTitle: NSLocalizedString("store_modal.action", comment: "Store modal"),
actionIcon: Theme.shared.images.storeIcon!,
onClose: {
SwiftEntryKit.dismiss()
Expand Down
12 changes: 6 additions & 6 deletions MobileWallet/Screens/AppEntry/Splash/SplashViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class SplashViewController: UIViewController, UITextViewDelegate {
let error: Error? = result?.object as? Error

UserFeedback.shared.error(
title: NSLocalizedString("Tor connection error", comment: "Splash screen"),
description: NSLocalizedString("Could not establish a connection to the network.", comment: "Splash screen"),
title: NSLocalizedString("tor.error.title", comment: "Tor error"),
description: NSLocalizedString("tor.error.description", comment: "Tor error"),
error: error
)
}
Expand Down Expand Up @@ -177,8 +177,8 @@ class SplashViewController: UIViewController, UITextViewDelegate {
} catch {
DispatchQueue.main.async {
UserFeedback.shared.error(
title: NSLocalizedString("Wallet error", comment: "Splash screen"),
description: NSLocalizedString("Error starting existing wallet", comment: "Splash screen"),
title: NSLocalizedString("wallet.error.title", comment: "Wallet error"),
description: NSLocalizedString("wallet.error.start_existing_wallet", comment: "Wallet error"),
error: error
)
}
Expand All @@ -200,8 +200,8 @@ class SplashViewController: UIViewController, UITextViewDelegate {
}
} catch {
UserFeedback.shared.error(
title: NSLocalizedString("Wallet error", comment: "Splash screen for new users"),
description: NSLocalizedString("Failed to create a new wallet", comment: "Splash screen for new users"),
title: NSLocalizedString("wallet.error.title", comment: "Wallet error"),
description: NSLocalizedString("wallet.error.create_new_wallet", comment: "Wallet error"),
error: error //TODO copy update
)

Expand Down
Loading

0 comments on commit b907831

Please sign in to comment.