taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit 0b015c0dcbc6d442d2677b3028c61037da8047e0
parent f7f01e56020c53ddc68ce4c69e5c28a2a2fafd13
Author: Marc Stibane <marc@taler.net>
Date:   Sat,  1 Jul 2023 15:02:27 +0200

Localization issues

Diffstat:
MTalerWallet1/Helper/EqualIconWidthDomain.swift | 30++++++++++++++++++------------
MTalerWallet1/Helper/TalerDater.swift | 22+++++++++++-----------
MTalerWallet1/Views/Balances/BalanceRowView.swift | 2+-
MTalerWallet1/Views/Balances/PendingRowView.swift | 3++-
MTalerWallet1/Views/Exchange/QuiteSomeCoins.swift | 13+++++++------
MTalerWallet1/Views/HelperViews/Buttons.swift | 2+-
MTalerWallet1/Views/Peer2peer/PaymentPurpose.swift | 2+-
MTalerWallet1/Views/Peer2peer/RequestPayment.swift | 2+-
MTalerWallet1/Views/Peer2peer/SendAmount.swift | 2+-
MTalerWallet1/Views/Peer2peer/SendPurpose.swift | 4++--
MTalerWallet1/Views/Settings/Pending/PendingOpView.swift | 11+++++++----
MTalerWallet1/Views/Settings/SettingsView.swift | 24++++++++++++------------
MTalerWallet1/Views/Transactions/ManualDetails.swift | 2+-
MTalerWallet1/Views/Transactions/TransactionDetailView.swift | 2+-
MTalerWallet1/Views/Transactions/TransactionRowView.swift | 7++++---
MTalerWallet1/Views/Transactions/TransactionsListView.swift | 5+++--
16 files changed, 73 insertions(+), 60 deletions(-)

diff --git a/TalerWallet1/Helper/EqualIconWidthDomain.swift b/TalerWallet1/Helper/EqualIconWidthDomain.swift @@ -85,17 +85,20 @@ struct EqualIconWidthDomain<Content: View>: View { struct Demo1View: View { var body: some View { VStack(alignment: .leading) { + let people = "People" + let star = "Star" + let plane = "This is a plane" VStack(alignment: .leading) { - Label("People", systemImage: "person.3") - Label("Star", systemImage: "star") - Label("This is a plane", systemImage: "airplane") + Label(people, systemImage: "person.3") + Label(star, systemImage: "star") + Label(plane, systemImage: "airplane") } .padding() EqualIconWidthDomain { VStack(alignment: .leading) { - Label("People", systemImage: "person.3") - Label("Star", systemImage: "star") - Label("This is a plane", systemImage: "airplane") + Label(people, systemImage: "person.3") + Label(star, systemImage: "star") + Label(plane, systemImage: "airplane") } } } @@ -113,19 +116,22 @@ struct FancyView: View { var body: some View { EqualIconWidthDomain { VStack { - Text("Le Menu") + let people = "People" + let star = "Star" + let money = "Money" + Text(verbatim: "Le Menu") .font(.caption) Divider() HStack { VStack(alignment: .leading) { Label( - title: { Text("Strawberry") }, - icon: { Text("🍓") }) - Label("Money", systemImage: "banknote") + title: { Text(verbatim: "Strawberry") }, + icon: { Text(verbatim: "🍓") }) + Label(money, systemImage: "banknote") } VStack(alignment: .leading) { - Label("People", systemImage: "person.3") - Label("Star", systemImage: "star") + Label(people, systemImage: "person.3") + Label(star, systemImage: "star") } } } diff --git a/TalerWallet1/Helper/TalerDater.swift b/TalerWallet1/Helper/TalerDater.swift @@ -11,24 +11,24 @@ public class TalerDater: DateFormatter { static func relativeDate(from: TimeInterval) -> String? { if from > 0 { // transactions should always be in the past let minute = from / 60.0 // from is in seconds - if minute < 1 { return "Right now" } - if minute < 2 { return "1 minute ago" } - if minute < 55 { return "\(Int(minute)) minutes ago" } - if minute < 60 { return "About an hour ago" } - if minute < 80 { return "1 hour ago" } - if minute < 105 { return "About 1½ hours ago" } - if minute < 125 { return "About 2 hours ago" } + if minute < 1 { return String(localized: "Right now") } + if minute < 2 { return String(localized: "1 minute ago") } + if minute < 55 { return String(localized: "\(Int(minute)) minutes ago") } + if minute < 60 { return String(localized: "About an hour ago") } + if minute < 80 { return String(localized: "1 hour ago") } + if minute < 105 { return String(localized: "About 1½ hours ago") } + if minute < 125 { return String(localized: "About 2 hours ago") } let hour = minute / 60.0 let calendar = Calendar.current let now = Date.now let currHour = Double(calendar.component(.hour, from: now)) let currMin = Double(calendar.component(.minute, from: now)) let currTime = currHour + currMin/60 - if hour < currTime { return "\(Int(hour)) hours ago" } - if hour < currTime + 24 { return "Yesterday" } + if hour < currTime { return String(localized: "\(Int(hour)) hours ago") } + if hour < currTime + 24 { return String(localized: "Yesterday") } let day = (hour - currTime) / 24.0 - if day < 7 { return "\(Int(day+1)) days ago" } - if day < 14 { return "More than a week ago" } + if day < 7 { return String(localized: "\(Int(day+1)) days ago") } + if day < 14 { return String(localized: "More than a week ago") } // will fall thru... return nil } else { // Yikes❗️ transaction date is in the future diff --git a/TalerWallet1/Views/Balances/BalanceRowView.swift b/TalerWallet1/Views/Balances/BalanceRowView.swift @@ -21,7 +21,7 @@ struct BalanceButton: View { Text("alance", comment: "the remaining letters of Balance - or all if you left B empty") .font(.footnote).bold() } - Text("\(amount.valueStr)") // TODO: CurrencyFormatter? + Text(verbatim: "\(amount.valueStr)") // TODO: CurrencyFormatter? .font(.title) } } .disabled(false) diff --git a/TalerWallet1/Views/Balances/PendingRowView.swift b/TalerWallet1/Views/Balances/PendingRowView.swift @@ -24,7 +24,8 @@ struct PendingRowView: View { Spacer() VStack(alignment: .trailing) { let sign = incoming ? "+" : "-" - Text(sign + "\(amount.valueStr)") + let valueStr = sign + amount.valueStr + Text(valueStr) .font(.title) .foregroundColor(WalletColors().pendingColor(incoming)) // Text("PENDING") diff --git a/TalerWallet1/Views/Exchange/QuiteSomeCoins.swift b/TalerWallet1/Views/Exchange/QuiteSomeCoins.swift @@ -55,17 +55,18 @@ struct QuiteSomeCoins: View { var body: some View { if shouldShowFee { - let shownFee = someCoins.hasFee ? String(localized: "- \(someCoins.fee)") - : String(localized: "No") - Text(someCoins.invalid ? "invalid amount" - : someCoins.tooMany ? "too many coins for a single withdrawal" - : "\(shownFee) withdrawal fee") + Text(someCoins.invalid ? "Invalid amount" + : someCoins.tooMany ? "Too many coins for a single withdrawal" + : someCoins.hasFee ? "- \(someCoins.fee) withdrawal fee" + : "No withdrawal fee") .foregroundColor((someCoins.invalid || someCoins.tooMany || someCoins.hasFee) ? .red : .primary) .padding(4) } if !someCoins.invalid { HStack { - Text(someCoins.unknown ? "Some" : "\(someCoins.numCoins)") + let coins: String = someCoins.unknown ? String(localized: "Some", comment: "unknown number of coins") + : "\(someCoins.numCoins)" + Text(coins) .foregroundColor(someCoins.quiteSome ? .red : .primary) Text(someCoins.tooMany ? "coins" : "coins to obtain:") .foregroundColor(someCoins.tooMany ? .red : .primary) diff --git a/TalerWallet1/Views/HelperViews/Buttons.swift b/TalerWallet1/Views/HelperViews/Buttons.swift @@ -233,7 +233,7 @@ fileprivate struct ContentView: View { var body: some View { VStack { - Text("I don't change.") + Text(verbatim: "I don't change.") .padding() Button("Press me, I do change") { isOn.toggle() diff --git a/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift b/TalerWallet1/Views/Peer2peer/PaymentPurpose.swift @@ -52,7 +52,7 @@ struct PaymentPurpose: View { HStack{ Spacer() - Text("\(summary.count)/100") + Text(verbatim: "\(summary.count)/100") } // maximum 100 characters Text("Expires in:") diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Peer2peer/RequestPayment.swift @@ -25,7 +25,7 @@ struct RequestPayment: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif let currency = scopeInfo.currency - let navTitle = String(localized: "Request \(currency)") + let navTitle = String(localized: "Request \(currency)", comment: "Request currency, Dialog Title") let currencyField = CurrencyField(value: $centsToTransfer, currency: currency) ScrollViewReader { scrollView in diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift b/TalerWallet1/Views/Peer2peer/SendAmount.swift @@ -36,7 +36,7 @@ struct SendAmount: View { let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif let currency = amountAvailable.currencyStr - let navTitle = String(localized: "Send \(currency)") + let navTitle = String(localized: "Send \(currency)", comment: "Send currency, Dialog Title") let currencyField = CurrencyField(value: $centsToTransfer, currency: currency) let fee = fee(ppCheck: peerPushCheck) diff --git a/TalerWallet1/Views/Peer2peer/SendPurpose.swift b/TalerWallet1/Views/Peer2peer/SendPurpose.swift @@ -51,7 +51,7 @@ struct SendPurpose: View { HStack{ Spacer() - Text("\(summary.count)/100") + Text(verbatim: "\(summary.count)/100") } // maximum 100 characters Text("Expires in:") @@ -69,7 +69,7 @@ struct SendPurpose: View { amountToReceive: nil, summary: summary, expireDays: expireDays) }) { - Text("Send \(label) \(amountAvailable.currencyStr) now") + Text("Send \(label) \(amountAvailable.currencyStr) now", comment: "first is value, second currencyString") .font(buttonFont) } .buttonStyle(TalerButtonStyle(type: .prominent)) diff --git a/TalerWallet1/Views/Settings/Pending/PendingOpView.swift b/TalerWallet1/Views/Settings/Pending/PendingOpView.swift @@ -18,14 +18,17 @@ struct PendingOpView: View { } Text(pendingOp.id) .font(.caption) - Toggle("isLongPolling", isOn: $polling) + let isLongPolling = "isLongPolling" + Toggle(isLongPolling, isOn: $polling) .disabled(true) - Toggle("givesLifeness", isOn: $liveliness) + let givesLifeness = "givesLifeness" + Toggle(givesLifeness, isOn: $liveliness) .disabled(true) - Toggle("isDue", isOn: $isDue) + let isDue = "isDue" + Toggle(isDue, isOn: $isDue) .disabled(true) let dateString = TalerDater.dateString(from: pendingOp.timestampDue) - Text("\(dateString)") + Text(dateString) } header: { Text(pendingOp.type) .font(.title2) diff --git a/TalerWallet1/Views/Settings/SettingsView.swift b/TalerWallet1/Views/Settings/SettingsView.swift @@ -145,23 +145,23 @@ struct SettingsView: View { } VStack { - SettingsItem(name: String(localized: "App Version")) { - Text("\(Bundle.main.releaseVersionNumberPretty)") + SettingsItem(name: "App Version") { + Text(verbatim: "\(Bundle.main.releaseVersionNumberPretty)") } - SettingsItem(name: String(localized: "Wallet Core Version")) { - Text("\(walletCore.versionInfo!.version)") + SettingsItem(name: "Wallet Core Version") { + Text(verbatim: "\(walletCore.versionInfo!.version)") } - SettingsItem(name: String(localized: "Wallet Core DevMode")) { - Text("\(walletCore.versionInfo!.devMode ? "YES" : "NO")") + SettingsItem(name: "Wallet Core DevMode") { + Text(verbatim: "\(walletCore.versionInfo!.devMode ? "YES" : "NO")") } - SettingsItem(name: String(localized: "Supported Exchange Versions")) { - Text("\(walletCore.versionInfo!.exchange)") + SettingsItem(name: "Supported Exchange Versions") { + Text(verbatim: "\(walletCore.versionInfo!.exchange)") } - SettingsItem(name: String(localized: "Supported Merchant Versions")) { - Text("\(walletCore.versionInfo!.merchant)") + SettingsItem(name: "Supported Merchant Versions") { + Text(verbatim: "\(walletCore.versionInfo!.merchant)") } - SettingsItem(name: String(localized: "Used Bank")) { - Text("\(walletCore.versionInfo!.bank)") + SettingsItem(name: "Used Bank") { + Text(verbatim: "\(walletCore.versionInfo!.bank)") } } } diff --git a/TalerWallet1/Views/Transactions/ManualDetails.swift b/TalerWallet1/Views/Transactions/ManualDetails.swift @@ -40,7 +40,7 @@ struct ManualDetails: View { HStack { Spacer() ShareButton(textToShare: payto) - .accessibilityLabel("Share PayTo ULR") + .accessibilityLabel("Share PayTo URL") .disabled(false) Spacer() } .listRowSeparator(.hidden) diff --git a/TalerWallet1/Views/Transactions/TransactionDetailView.swift b/TalerWallet1/Views/Transactions/TransactionDetailView.swift @@ -65,7 +65,7 @@ struct TransactionDetailView: View { command: .resume, action: resumeAction) } } } // Suspend + Resume buttons - Text("\(dateString)") + Text(dateString) .font(.title2) // .listRowSeparator(.hidden) SwitchCase(transaction: $transaction) diff --git a/TalerWallet1/Views/Transactions/TransactionRowView.swift b/TalerWallet1/Views/Transactions/TransactionRowView.swift @@ -11,11 +11,11 @@ struct TransactionRowCenter: View { var body: some View { VStack(alignment: .leading) { - Text("\(centerTop)") + Text(centerTop) .font(.headline) .fontWeight(.medium) .padding(.bottom, -2.0) - Text("\(centerBottom)") + Text(centerBottom) .font(.callout) } } @@ -49,7 +49,8 @@ struct TransactionRowView: View { Spacer() VStack(alignment: .trailing) { let sign = incoming ? "+" : "-" - Text(sign + "\(amount.valueStr)") + let valueStr = sign + amount.valueStr + Text(valueStr) .font(.title) .foregroundColor(foreColor) } diff --git a/TalerWallet1/Views/Transactions/TransactionsListView.swift b/TalerWallet1/Views/Transactions/TransactionsListView.swift @@ -23,14 +23,15 @@ struct TransactionsListView: View { let count = transactions.count // TODO: Unlock the power of grammatical agreement // let title = AttributedString(localized: "^[\(count) Ticket](inflect: true)") - let title: String = "\(count) \(navTitle)" +// let title: String = "\(count) \(navTitle)" Content(symLog: symLog, currency: currency, transactions: transactions, myListStyle: $myListStyle, reloadAllAction: reloadAllAction, reloadOneAction: reloadOneAction) - .navigationTitle(title) +// .navigationTitle(title) + .navigationTitle(navTitle) .navigationBarTitleDisplayMode(.large) // .inline .onAppear { DebugViewC.shared.setViewID(VIEW_TRANSACTIONLIST)