taler-ios

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

commit 7095d51ce5d47ff5c56833857ec13106d59a9b24
parent 8d7e9ad68f1f0794184ab069eed7074e610307b4
Author: Marc Stibane <marc@taler.net>
Date:   Mon,  5 Oct 2026 07:55:12 +0200

Use .localized

Diffstat:
MTalerWallet1/Backend/WalletBackendRequest.swift | 4++++
MTalerWallet1/Model/Model+Payment.swift | 20++++++--------------
MTalerWallet1/Model/Model+Withdraw.swift | 4+---
MTalerWallet1/Model/Transaction.swift | 2+-
MTalerWallet1/Views/Sheets/Payment/ChoicesView.swift | 2+-
MTalerWallet1/Views/Transactions/ManualDetailsWireV.swift | 2+-
MTalerWallet1/Views/Transactions/PaymentTransactionView.swift | 39++++++---------------------------------
MTalerWallet1/Views/Transactions/TransactionPayDetailV.swift | 2+-
8 files changed, 21 insertions(+), 54 deletions(-)

diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift b/TalerWallet1/Backend/WalletBackendRequest.swift @@ -164,6 +164,10 @@ struct OrderShortInfo: Codable { var fulfillmentMessage: String? var fulfillmentMessage_i18n: I18nDict? var contractTermsHash: String? + + var locSummary: String { + self.summary_i18n?.localized ?? self.summary + } } // MARK: - /// A request to force update an exchange. diff --git a/TalerWallet1/Model/Model+Payment.swift b/TalerWallet1/Model/Model+Payment.swift @@ -198,20 +198,8 @@ struct ContractChoice: Codable, Hashable { case inputs, outputs } - var descI18n: String? { - if let i18nDict = self.descriptionI18n { - if !i18nDict.isEmpty { - for code in Locale.preferredLanguageCodes { - if let descI18n = i18nDict[code] { - return descI18n - } - } - } - } - if let desc = self.description { - return desc - } - return nil + var locDescription: String? { + self.descriptionI18n?.localized ?? self.description } } @@ -294,6 +282,10 @@ struct MerchantContractTerms: Codable { case choices case tokenFamilies = "token_families" } + + var locSummary: String { + self.summaryI18n?.localized ?? self.summary + } } // MARK: - Auditor struct Auditor: Codable { diff --git a/TalerWallet1/Model/Model+Withdraw.swift b/TalerWallet1/Model/Model+Withdraw.swift @@ -14,13 +14,11 @@ enum AccountRestrictionType: String, Codable { case regex } -typealias HintDict = [String:String] - struct AccountRestriction: Codable, Hashable { var type: AccountRestrictionType var payto_regex: String? var human_hint: String? - var human_hint_i18n: HintDict? + var human_hint_i18n: I18nDict? } extension AccountRestriction: Identifiable { var id: AccountRestriction {self} diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift @@ -828,7 +828,7 @@ enum TalerTransaction: Decodable, Hashable, Identifiable, Sendable { case .deposit(let depositTransaction): result[EXCHANGEBASEURL] = depositTransaction.details.depositGroupId case .payment(let paymentTransaction): - result["summary"] = paymentTransaction.details.info?.summary ?? EMPTYSTRING + result["summary"] = paymentTransaction.details.info?.locSummary ?? EMPTYSTRING case .refund(let refundTransaction): if let info = refundTransaction.details.paymentInfo { result["summary"] = info.summary diff --git a/TalerWallet1/Views/Sheets/Payment/ChoicesView.swift b/TalerWallet1/Views/Sheets/Payment/ChoicesView.swift @@ -74,7 +74,7 @@ struct ChoicesView: View, Sendable { } } header: { if showHeader { - if let description = contractChoice.descI18n { + if let description = contractChoice.locDescription { Text(description) } } } } diff --git a/TalerWallet1/Views/Transactions/ManualDetailsWireV.swift b/TalerWallet1/Views/Transactions/ManualDetailsWireV.swift @@ -66,7 +66,7 @@ struct TransferRestrictionsV: View { } // MARK: - struct RestrictionsV: View { - let hintsI18n: HintDict + let hintsI18n: I18nDict var human_hint: String? @State private var selectedLanguage = Locale.preferredLanguageCode diff --git a/TalerWallet1/Views/Transactions/PaymentTransactionView.swift b/TalerWallet1/Views/Transactions/PaymentTransactionView.swift @@ -15,23 +15,10 @@ struct MerchantHeader: View { @State private var image: Image? = nil - func summary(_ terms: MerchantContractTerms) -> String { - if let i18nDict = terms.summaryI18n { - if !i18nDict.isEmpty { - for code in Locale.preferredLanguageCodes { - if let descI18n = i18nDict[code] { - return descI18n - } - } - } - } - return terms.summary - } - var body: some View { if let terms { Section { - Text(summary(terms)) + Text(terms.locSummary) .talerFont(.title3) } header: { HStack { @@ -82,22 +69,6 @@ struct PaymentTransactionView: View { @EnvironmentObject private var controller: Controller @EnvironmentObject private var model: WalletModel - func summary(_ info: OrderShortInfo?) -> String? { - if let i18nDict = info?.summary_i18n { - if !i18nDict.isEmpty { - for code in Locale.preferredLanguageCodes { - if let i18n = i18nDict[code] { - return i18n - } - } - } - } - if let summary = info?.summary { - return summary - } - return String(localized: "No summary", comment: "OrderShortInfo.summary") - } - func selectIndex(_ index: Int?, of choices: [ChoiceTriple]) -> Int? { let index1 = index ?? 0 let select = index1 < choices.count ? index1 : 0 @@ -180,6 +151,8 @@ struct PaymentTransactionView: View { } } + let summary = details.info?.locSummary ?? + String(localized: "No summary", comment: "OrderShortInfo.summary") if let selectedChoice { let choice = choices[selectedChoice] let selectionDetail: ChoiceSelectionDetail = choice.0 @@ -191,7 +164,7 @@ struct PaymentTransactionView: View { effective: effective, firstScope: scope, baseURL: nil, - summary: summary(details.info), + summary: summary, products: details.info?.products ?? [], balanceDetails: selectionDetail.balanceDetails) } else if let choice = choices.first { @@ -203,7 +176,7 @@ struct PaymentTransactionView: View { effective: nil, firstScope: scope, baseURL: nil, - summary: summary(details.info), + summary: summary, products: details.info?.products ?? [], balanceDetails: selectionDetail.balanceDetails) } @@ -226,7 +199,7 @@ struct PaymentTransactionView: View { noFees: nil, // TODO: noFees feeIsNegative: false, large: true, - summary: details.info?.summary ?? EMPTYSTRING) + summary: details.info?.locSummary ?? EMPTYSTRING) } // show finished payment } // body } // PaymentTransactionView diff --git a/TalerWallet1/Views/Transactions/TransactionPayDetailV.swift b/TalerWallet1/Views/Transactions/TransactionPayDetailV.swift @@ -89,7 +89,7 @@ struct TransactionPayDetailV: View { if let choices = contractTerms.choices, choices.indices.contains(choiceIndex) { let choice = choices[choiceIndex] - Text(choice.descI18n ?? "Index: \(choiceIndex)") // should never happen + Text(choice.locDescription ?? "Index: \(choiceIndex)") // fallback should never happen .talerFont(.body) } }