Skip to content

Commit 3a0813e

Browse files
committed
Readable keys.
1 parent c920615 commit 3a0813e

10 files changed

+81
-77
lines changed

Adamant/Helpers/String+localized.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import Foundation
1111
extension String {
1212
public struct adamantLocalized {
1313
struct shared {
14-
static let productName = NSLocalizedString("adamant", comment: "Adamant: a product name")
14+
static let productName = NSLocalizedString("Adamant", comment: "Product name")
1515

1616
private init() {}
1717
}
1818

1919
struct alert {
20-
static let cancel = NSLocalizedString("shared.button.cancel", comment: "Shared alert 'Cancel' button. Used anywhere")
21-
static let ok = NSLocalizedString("shared.button.ok", comment: "Shared alert 'Ok' button. Used anywhere")
22-
static let save = NSLocalizedString("shared.button.save", comment: "Shared alert 'Save' button. Used anywhere")
23-
static let copyToPasteboard = NSLocalizedString("shared.button.copy-to-pasteboard", comment: "Shared alert 'Copy to pasteboard' button. Used anywhere. Used for copy-paste info.")
24-
static let copiedToPasteboardNotification = NSLocalizedString("shared.notification.copied_to_pasteboard", comment: "Shared alert notification: message about item copied to pasteboard.")
25-
static let share = NSLocalizedString("shared.button.share", comment: "Shared alert 'Share' button. Used anywhere for presenting standart iOS 'Share' menu.")
20+
static let cancel = NSLocalizedString("Cancel", comment: "Shared alert 'Cancel' button. Used anywhere")
21+
static let ok = NSLocalizedString("Ok", comment: "Shared alert 'Ok' button. Used anywhere")
22+
static let save = NSLocalizedString("Save", comment: "Shared alert 'Save' button. Used anywhere")
23+
static let copyToPasteboard = NSLocalizedString("Copy to Pasteboard", comment: "Shared alert 'Copy' button. Used anywhere. Used for copy-paste info.")
24+
static let copiedToPasteboardNotification = NSLocalizedString("Copied to Pasteboard", comment: "Shared alert notification: message about item copied to pasteboard.")
25+
static let share = NSLocalizedString("Share", comment: "Shared alert 'Share' button. Used anywhere for presenting standart iOS 'Share' menu.")
2626
}
2727

2828
private init() { }

Adamant/ServiceProtocols/ApiService.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,26 @@ enum ApiServiceError: Error {
2323
var localized: String {
2424
switch self {
2525
case .notLogged:
26-
return NSLocalizedString("apiService.errors.user-not-logged", comment: "User not logged")
26+
return NSLocalizedString("User not logged", comment: "User not logged error")
2727

2828
case .accountNotFound:
29-
return NSLocalizedString("apiService.errors.account-not-found-format", comment: "Account not found: %@")
29+
return NSLocalizedString("Account not found: %@", comment: "Account not found error, appending account info.")
3030

3131
case .serverError(error: let error):
32-
return String.localizedStringWithFormat(NSLocalizedString("apiService.errors.remote-server-error-format", comment: "Remote server error: %@"), error)
33-
34-
case .internalError(_, let error as ApiServiceError):
35-
return String.localizedStringWithFormat(NSLocalizedString("apiService.errors.internal-error-format", comment: "Internal error: %@"), error.localized)
32+
return String.localizedStringWithFormat(NSLocalizedString("Remote Server error: %@", comment: "Remote server returned an error"), error)
3633

3734
case .internalError(_, let error):
38-
return String.localizedStringWithFormat(NSLocalizedString("apiService.errors.internal-error-format", comment: "Internal error: %@"), String(describing: error))
35+
let message: String
36+
if let apiError = error as? ApiServiceError {
37+
message = apiError.localized
38+
} else {
39+
message = String(describing: error)
40+
}
41+
42+
return String.localizedStringWithFormat(NSLocalizedString("Internal error: %@", comment: "Internal application error"), message)
3943

4044
case .networkError(error: _):
41-
return NSLocalizedString("apiService.errors.connection-failed", comment: "No connection message")
45+
return NSLocalizedString("No connection", comment: "No connection message. Generally bad network.")
4246
}
4347
}
4448
}

Adamant/Services/ApiService/AdamantApiService.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ class AdamantApiService: ApiService {
3333
var localized: String {
3434
switch self {
3535
case .endpointBuildFailed:
36-
return NSLocalizedString("apiService.internal-error.endpoint-failed", comment: "Failed to build endpoint url")
36+
return NSLocalizedString("Endpoint build failed", comment: "Serious internal error: Failed to build endpoint url")
3737

3838
case .signTransactionFailed:
39-
return NSLocalizedString("apiService.internal-error.failed-signing", comment: "Failed to sign transaction")
39+
return NSLocalizedString("Failed transaction signing", comment: "Serious internal error: Failed to sign transaction")
4040

4141
case .parsingFailed:
42-
return NSLocalizedString("apiService.internal-error.parsing-failed", comment: "Error parsing response")
42+
return NSLocalizedString("Parsing failed", comment: "Serious internal error: Error parsing response")
4343

4444
case .unknownError:
45-
return NSLocalizedString("apiService.internal-error.unknown-error", comment: "Unknown error")
45+
return NSLocalizedString("Unknown error", comment: "Unknown internal error")
4646
}
4747
}
4848
}

Adamant/Stories/Account/AccountViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ import SafariServices
1313
// MARK: - Localization
1414
extension String.adamantLocalized {
1515
struct account {
16-
static let rowBalance = NSLocalizedString("account.rows.Balance", comment: "Wallet page: Balance row title")
17-
static let rowSendTokens = NSLocalizedString("account.rows.Send-Tokens", comment: "Wallet page: 'Send tokens' button")
18-
static let rowInvest = NSLocalizedString("account.rows.Invest-in-ICO", comment: "Wallet page: 'Invest in ICO' button")
16+
static let rowBalance = NSLocalizedString("Balance", comment: "Wallet page: Balance row title")
17+
static let rowSendTokens = NSLocalizedString("Send Tokens", comment: "Wallet page: 'Send tokens' button")
18+
static let rowInvest = NSLocalizedString("Invest in ICO", comment: "Wallet page: 'Invest in ICO' button")
1919
static let rowLogout = NSLocalizedString("Logout", comment: "Wallet page: 'Logout' button")
2020

21-
static let sectionAccount = NSLocalizedString("account.sections.Account", comment: "Wallet page: Account section title.")
22-
static let sectionWallet = NSLocalizedString("account.sections.Wallet", comment: "Wallet page: Wallet section title")
23-
static let sectionActions = NSLocalizedString("account.sections.Actions", comment: "Wallet page: Actions section title")
21+
static let sectionAccount = NSLocalizedString("Account", comment: "Wallet page: Account section title.")
22+
static let sectionWallet = NSLocalizedString("Wallet", comment: "Wallet page: Wallet section title")
23+
static let sectionActions = NSLocalizedString("Actions", comment: "Wallet page: Actions section title")
2424

2525
private init() { }
2626
}
2727
}
2828

2929
fileprivate extension String.adamantLocalized.alert {
30-
static let logoutMessageFormat = NSLocalizedString("account.alert.logout-message-format", comment: "Confirm logout alert: 'Confirm logout from %@' message format")
31-
static let logoutButton = NSLocalizedString("account.alert.logout", comment: "Confirm logout alert: Logout (Ok) button")
30+
static let logoutMessageFormat = NSLocalizedString("Logout from %@?", comment: "Confirm logout alert")
31+
static let logoutButton = NSLocalizedString("Logout", comment: "Confirm logout alert: Logout (Ok) button")
3232
}
3333

3434

Adamant/Stories/Account/TransactionDetailsViewController.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class TransactionDetailsViewController: UIViewController {
3434

3535
var localized: String {
3636
switch self {
37-
case .transactionNumber: return NSLocalizedString("transaction-details.rows.id", comment: "Transaction Id row.")
38-
case .from: return NSLocalizedString("transaction-details.rows.from", comment: "Transaction sender row.")
39-
case .to: return NSLocalizedString("transaction-details.rows.to", comment: "Transaction recipient row.")
40-
case .date: return NSLocalizedString("transaction-details.rows.date", comment: "Transaction date row.")
41-
case .amount: return NSLocalizedString("transaction-details.rows.amount", comment: "Transaction amount row.")
42-
case .fee: return NSLocalizedString("transaction-details.rows.fee", comment: "Transaction fee row.")
43-
case .confirmations: return NSLocalizedString("transaction-details.rows.confirmations", comment: "Transaction confirmations row.")
44-
case .block: return NSLocalizedString("transaction-details.rows.block", comment: "Transaction Block id row.")
45-
case .openInExplorer: return NSLocalizedString("transaction-details.rows.openInExplorer", comment: "'Open transaction in explorer' row.")
37+
case .transactionNumber: return NSLocalizedString("Transaction #", comment: "Transaction Id row.")
38+
case .from: return NSLocalizedString("From", comment: "Transaction sender row.")
39+
case .to: return NSLocalizedString("To", comment: "Transaction recipient row.")
40+
case .date: return NSLocalizedString("Date", comment: "Transaction date row.")
41+
case .amount: return NSLocalizedString("Amount", comment: "Transaction amount row.")
42+
case .fee: return NSLocalizedString("Fee", comment: "Transaction fee row.")
43+
case .confirmations: return NSLocalizedString("Confirmations", comment: "Transaction confirmations row.")
44+
case .block: return NSLocalizedString("Block", comment: "Transaction Block id row.")
45+
case .openInExplorer: return NSLocalizedString("Open in Explorer", comment: "'Open transaction in explorer' row.")
4646
}
4747
}
4848
}

Adamant/Stories/Account/TransferViewController.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ import Eureka
1313
// MARK: - Localization
1414
extension String.adamantLocalized {
1515
struct transfer {
16-
static let addressPlaceholder = NSLocalizedString("transfer.rows.address-placeholder", comment: "Transfer row: recipient address placeholder")
17-
static let amountPlaceholder = NSLocalizedString("transfer.rows.amount-placeholder", comment: "Transfer row: transfer amount placeholder")
16+
static let addressPlaceholder = NSLocalizedString("of the recipient", comment: "Transfer row: recipient address placeholder")
17+
static let amountPlaceholder = NSLocalizedString("to send", comment: "Transfer row: transfer amount placeholder")
1818

19-
static let addressValidationError = NSLocalizedString("transfer.errors.incorrect-address", comment: "Address validation error")
20-
static let amountZeroError = NSLocalizedString("transfer.errors.too-small-amount", comment: "Amount is zero, or even negative")
21-
static let amountTooHigh = NSLocalizedString("transfer.errors.not-enough-money", comment: "Amount is hiegher that user's total money")
22-
static let accountNotFound = NSLocalizedString("transfer.account-not-found", comment: "Transfer error: Account not found")
19+
static let addressValidationError = NSLocalizedString("Please enter a valid recipient address", comment: "Address validation error")
20+
static let amountZeroError = NSLocalizedString("You should send more money", comment: "Amount is zero, or even negative")
21+
static let amountTooHigh = NSLocalizedString("You don't have that much money", comment: "Amount is hiegher that user's total money")
22+
static let accountNotFound = NSLocalizedString("Account not found", comment: "Transfer error: Account not found")
2323

24-
static let transferProcessingMessage = NSLocalizedString("transfer.transfer-processing-message", comment: "Transfer processing message")
25-
static let transferSuccess = NSLocalizedString("transfer.success-message", comment: "Tokens transfered successfully message")
24+
static let transferProcessingMessage = NSLocalizedString("Sending funds...", comment: "Transfer processing message")
25+
static let transferSuccess = NSLocalizedString("Funds sended!", comment: "Tokens transfered successfully message")
2626

2727
private init() { }
2828
}
2929
}
3030

3131
fileprivate extension String.adamantLocalized.alert {
3232
static let confirmSendMessageFormat = NSLocalizedString("Send %1$@ to %2$@?", comment: "Confirm transfer X tokens to Y message. Note two variables: at runtime %1$@ will be amount (with ADM suffix), and %2$@ will be recipient address. You can use address before amount with this so called 'position tokens'.")
33-
static let send = NSLocalizedString("transfer.alert.send-button", comment: "Confirm transfer and send tokens button")
33+
static let send = NSLocalizedString("Send", comment: "Confirm transfer alert: Send tokens button")
3434
}
3535

3636

@@ -62,13 +62,13 @@ class TransferViewController: FormViewController {
6262

6363
var localized: String {
6464
switch self {
65-
case .balance: return NSLocalizedString("transfer.rows.balance", comment: "Transfer row: logged user balance.")
66-
case .amount: return NSLocalizedString("transfer.rows.amount", comment: "Transfer row: amount of adamant to transfer.")
67-
case .maxToTransfer: return NSLocalizedString("transfer.rows.maxToTransfer", comment: "Transfer row: maximum amount to transfer: available account money substracting transfer fee.")
68-
case .address: return NSLocalizedString("transfer.rows.address", comment: "Transfer row: recipient address")
69-
case .fee: return NSLocalizedString("transfer.rows.fee", comment: "Transfer row: transfer fee")
70-
case .total: return NSLocalizedString("transfer.rows.total", comment: "Transfer row: total amount of transaction: money to transfer adding fee")
71-
case .sendButton: return NSLocalizedString("transfer.rows.sendButton", comment: "Transfer row: Send button")
65+
case .balance: return NSLocalizedString("Balance", comment: "Transfer row: logged user balance.")
66+
case .amount: return NSLocalizedString("Amount", comment: "Transfer row: amount of adamant to transfer.")
67+
case .maxToTransfer: return NSLocalizedString("Max to transfer", comment: "Transfer row: maximum amount to transfer: available account money substracting transfer fee.")
68+
case .address: return NSLocalizedString("Address", comment: "Transfer row: recipient address")
69+
case .fee: return NSLocalizedString("Transaction fee", comment: "Transfer row: transfer fee")
70+
case .total: return NSLocalizedString("Total", comment: "Transfer row: total amount of transaction: money to transfer adding fee")
71+
case .sendButton: return NSLocalizedString("Send Funds", comment: "Transfer row: Send button")
7272
}
7373
}
7474
}
@@ -79,8 +79,8 @@ class TransferViewController: FormViewController {
7979

8080
var localized: String {
8181
switch self {
82-
case .wallet: return NSLocalizedString("transfer.sections.wallet", comment: "Transfer section: 'Your wallet' section")
83-
case .transferInfo: return NSLocalizedString("transfer.sections.transferInfo", comment: "Transfer section: 'Transfer info' section")
82+
case .wallet: return NSLocalizedString("Your wallet", comment: "Transfer section: 'Your wallet' section")
83+
case .transferInfo: return NSLocalizedString("Transfer Info", comment: "Transfer section: 'Transfer info' section")
8484
}
8585
}
8686
}

Adamant/Stories/Chats/ChatViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import CoreData
1313
// MARK: - Localization
1414
extension String.adamantLocalized {
1515
struct chat {
16-
static let estimatedFeeFormat = NSLocalizedString("chat.estimated-fee", comment: "Estimated fee: %f")
16+
static let estimatedFeeFormat = NSLocalizedString("Estimated fee: %f", comment: "Chat input bar: Estimated fee.")
1717

18-
static let messageIsEmpty = NSLocalizedString("chat.message-is-empty", comment: "Notify user that message cannot be empty")
19-
static let messageTooLong = NSLocalizedString("chat.message-too-long", comment: "Message is too long")
20-
static let notEnoughMoney = NSLocalizedString("chat.not-enough", comment: "You don't have enough money to send a message.")
18+
static let messageIsEmpty = NSLocalizedString("Message is empty", comment: "Notify user that message cannot be empty")
19+
static let messageTooLong = NSLocalizedString("Message is too long", comment: "Message is too long")
20+
static let notEnoughMoney = NSLocalizedString("You don't have enough money to send a message", comment: "Notify user that he doesn't have money to pay a message fee")
2121

22-
static let internalErrorFormat = NSLocalizedString("chat.internal-error-format", comment: "Internal error: %@")
23-
static let serverErrorFormat = NSLocalizedString("chat.server-error-format", comment: "Remote server error: %@")
22+
static let internalErrorFormat = NSLocalizedString("Internal error: %@. You should report this bug.", comment: "Notify user about bad internal error. Usually this should be reported as a bug.")
23+
static let serverErrorFormat = NSLocalizedString("Remote server error: %@", comment: "Notify user about server error.")
2424

2525
private init() { }
2626
}

Adamant/Stories/Chats/NewChatViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import UIKit
1111
// MARK: - Localization
1212
extension String.adamantLocalized {
1313
struct newChat {
14-
static let addressPlaceholder = NSLocalizedString("newChat.address-placeholder", comment: "Recipient address placeholder. Note that address text field always shows U letter, so you can left this line blank.")
14+
static let addressPlaceholder = NSLocalizedString("", comment: "Recipient address placeholder. Note that address text field always shows U letter, so you can left this line blank.")
1515

16-
static let specifyValidAddressMessage = NSLocalizedString("newChat.specify-valid-address-message", comment: "Please specify valid recipient address")
17-
static let loggedUserAddressMessage = NSLocalizedString("newChat.logged-user-address-message", comment: "Notify user that he can't start chat with himself")
16+
static let specifyValidAddressMessage = NSLocalizedString("Please specify valid recipient address", comment: "Notify user that he entered invalid address")
17+
static let loggedUserAddressMessage = NSLocalizedString("You don't need an encrypted anonymous chat to talk to yourself", comment: "Notify user that he can't start chat with himself")
1818

19-
static let addressNotFoundFormat = NSLocalizedString("newChat.address-not-found-format", comment: "Address %@ not found")
20-
static let serverErrorFormat = NSLocalizedString("chat.server-error-format", comment: "Remote server error: %@")
19+
static let addressNotFoundFormat = NSLocalizedString("Address %@ not found", comment: "Notify user that specified address (%@) not found")
20+
static let serverErrorFormat = NSLocalizedString("%@", comment: "Remote server returned an error.")
2121

2222
private init() { }
2323
}
@@ -112,7 +112,7 @@ class NewChatViewController: UITableViewController {
112112
self.dialogService.showError(withMessage: String.localizedStringWithFormat(String.adamantLocalized.newChat.addressNotFoundFormat, address))
113113

114114
case .serverError(let error):
115-
self.dialogService.showError(withMessage: String(describing: error))
115+
self.dialogService.showError(withMessage: String.localizedStringWithFormat(String.adamantLocalized.newChat.serverErrorFormat, String(describing: error)))
116116
}
117117
}
118118
}

0 commit comments

Comments
 (0)