Implemented translating texts for alert to ask user if account should be deleted?
This commit is contained in:
parent
4607d521b5
commit
b24434571a
|
@ -21,6 +21,19 @@ extension String {
|
||||||
return NSLocalizedString(self, comment: "")
|
return NSLocalizedString(self, comment: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: implement passing multiple arguments to localize()
|
||||||
|
// func localize(_ arguments: CVarArg...) -> String {
|
||||||
|
// return localize(arguments)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func localize(_ arguments: [CVarArg]) -> String {
|
||||||
|
// return String(format: NSLocalizedString(self, comment: ""), arguments)
|
||||||
|
// }
|
||||||
|
|
||||||
|
func localize(_ arguments: CVarArg) -> String {
|
||||||
|
return String(format: NSLocalizedString(self, comment: ""), arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
subscript(_ i: Int) -> String {
|
subscript(_ i: Int) -> String {
|
||||||
let idx1 = index(startIndex, offsetBy: i)
|
let idx1 = index(startIndex, offsetBy: i)
|
||||||
|
|
|
@ -49,10 +49,12 @@ struct BankListItem : View {
|
||||||
func askUserToDeleteAccount() {
|
func askUserToDeleteAccount() {
|
||||||
// couldn't believe it, .alert() didn't work as SwiftUI resetted @State variable to dislpay it instantly, therefore Alert never got displayed
|
// couldn't believe it, .alert() didn't work as SwiftUI resetted @State variable to dislpay it instantly, therefore Alert never got displayed
|
||||||
// TODO: use values from Message.createAskUserToDeleteAccountMessage(self.bank, self.deleteAccount)
|
// TODO: use values from Message.createAskUserToDeleteAccountMessage(self.bank, self.deleteAccount)
|
||||||
let alert = UIAlertController(title: "Delete account?", message: "Really delete account '\(bank.displayName)'? This cannot be undone and data will be lost.", preferredStyle: .alert)
|
let alert = UIAlertController(title: "Delete account?".localize(),
|
||||||
|
message: "Really delete account '%@'? This cannot be undone and data will be lost.".localize(bank.displayName),
|
||||||
|
preferredStyle: .alert)
|
||||||
|
|
||||||
alert.addAction(UIAlertAction(title: "Delete", style: .destructive, handler: { _ in self.deleteAccount(self.bank) } ))
|
alert.addAction(UIAlertAction(title: "Delete".localize(), style: .destructive, handler: { _ in self.deleteAccount(self.bank) } ))
|
||||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
alert.addAction(UIAlertAction(title: "Cancel".localize(), style: .cancel, handler: nil))
|
||||||
|
|
||||||
if let rootViewController = SceneDelegate.rootNavigationController {
|
if let rootViewController = SceneDelegate.rootNavigationController {
|
||||||
rootViewController.present(alert, animated: true)
|
rootViewController.present(alert, animated: true)
|
||||||
|
|
Loading…
Reference in New Issue