diff --git a/Bark.xcodeproj/project.pbxproj b/Bark.xcodeproj/project.pbxproj index f93bd0a..feb012c 100644 --- a/Bark.xcodeproj/project.pbxproj +++ b/Bark.xcodeproj/project.pbxproj @@ -104,7 +104,6 @@ 066E0C8C2BB6AC9A00873838 /* AddSoundCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 066E0C8B2BB6AC9A00873838 /* AddSoundCell.swift */; }; 0672CB06256903F700570C9D /* MessageListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0672CB05256903F700570C9D /* MessageListViewModel.swift */; }; 06787C392A710568008ABDD7 /* GesturePassTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06787C382A710568008ABDD7 /* GesturePassTextView.swift */; }; - 06787C3B2AB82BDB008ABDD7 /* CrashReportViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06787C3A2AB82BDB008ABDD7 /* CrashReportViewController.swift */; }; 067AFB1C2E5D8BE300AE78E7 /* UNNotificationContent+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 067AFB1B2E5D8BE300AE78E7 /* UNNotificationContent+Extension.swift */; }; 067AFB1D2E5D8BED00AE78E7 /* UNNotificationContent+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 067AFB1B2E5D8BE300AE78E7 /* UNNotificationContent+Extension.swift */; }; 067B2EB525693E38008B6BE1 /* MessageSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 067B2EB425693E38008B6BE1 /* MessageSection.swift */; }; @@ -119,6 +118,8 @@ 068EC15827ED99C900D5D11E /* ServerListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068EC15727ED99C900D5D11E /* ServerListViewController.swift */; }; 068EC15A27ED99E700D5D11E /* ServerListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068EC15927ED99E700D5D11E /* ServerListViewModel.swift */; }; 068F66B3247BD84C00DAD25A /* MessageListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 068F66B2247BD84C00DAD25A /* MessageListViewController.swift */; }; + 069332222E6A8E3100F9387F /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706A20E20A7C00F4CA05 /* String+Extension.swift */; }; + 069332232E6A8E3100F9387F /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706A20E20A7C00F4CA05 /* String+Extension.swift */; }; 0699473D2D223094008D5E40 /* CustomTapTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0699473C2D223094008D5E40 /* CustomTapTextView.swift */; }; 06B1158D247BA6D5006D91FB /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06B1158C247BA6D5006D91FB /* CloudKit.framework */; }; 06B1158F247BB1FB006D91FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B1158E247BB1FB006D91FB /* Message.swift */; }; @@ -199,8 +200,6 @@ 06F08EA529B1DDA7006AB9CA /* Algorithm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 061894C629A75BEA00E001C2 /* Algorithm.swift */; }; 06F08EA729B1DDFE006AB9CA /* Error+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F08EA629B1DDFE006AB9CA /* Error+Extension.swift */; }; 06F08EA829B1DE0A006AB9CA /* Error+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F08EA629B1DDFE006AB9CA /* Error+Extension.swift */; }; - 06F08EAC29B1DECD006AB9CA /* NSLocalizedString+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F08EAB29B1DECD006AB9CA /* NSLocalizedString+Extension.swift */; }; - 06F08EAD29B1DED6006AB9CA /* NSLocalizedString+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F08EAB29B1DECD006AB9CA /* NSLocalizedString+Extension.swift */; }; 06F08EAF29B5D9FF006AB9CA /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F08EAE29B5D9FF006AB9CA /* HUD.swift */; }; 06F11E7727D9D5FB00F00298 /* QRScannerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06F11E7627D9D5FB00F00298 /* QRScannerViewController.swift */; }; 06FB04042C53575400F3A213 /* SharedDefines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FB04032C53575400F3A213 /* SharedDefines.swift */; }; @@ -351,7 +350,6 @@ 066E0C8B2BB6AC9A00873838 /* AddSoundCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSoundCell.swift; sourceTree = ""; }; 0672CB05256903F700570C9D /* MessageListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewModel.swift; sourceTree = ""; }; 06787C382A710568008ABDD7 /* GesturePassTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GesturePassTextView.swift; sourceTree = ""; }; - 06787C3A2AB82BDB008ABDD7 /* CrashReportViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReportViewController.swift; sourceTree = ""; }; 067AFB1B2E5D8BE300AE78E7 /* UNNotificationContent+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "UNNotificationContent+Extension.swift"; path = "notificationContentExtension/UNNotificationContent+Extension.swift"; sourceTree = SOURCE_ROOT; }; 067B2EB425693E38008B6BE1 /* MessageSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageSection.swift; sourceTree = ""; }; 0683486A2050F1310024B6DA /* Bark.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Bark.entitlements; sourceTree = ""; }; @@ -411,7 +409,6 @@ 06EF49182D682B34008B91D2 /* PushToOtherIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushToOtherIntent.swift; sourceTree = ""; }; 06F08EA329B098DD006AB9CA /* CryptoSettingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoSettingManager.swift; sourceTree = ""; }; 06F08EA629B1DDFE006AB9CA /* Error+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Error+Extension.swift"; sourceTree = ""; }; - 06F08EAB29B1DECD006AB9CA /* NSLocalizedString+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLocalizedString+Extension.swift"; sourceTree = ""; }; 06F08EAE29B5D9FF006AB9CA /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; 06F11E7627D9D5FB00F00298 /* QRScannerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRScannerViewController.swift; sourceTree = ""; }; 06FB04032C53575400F3A213 /* SharedDefines.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedDefines.swift; sourceTree = ""; }; @@ -492,7 +489,6 @@ 068EC15927ED99E700D5D11E /* ServerListViewModel.swift */, 06EEF332291CCFF400CA228A /* CryptoSettingController.swift */, 06EEF334291CD00000CA228A /* CryptoSettingViewModel.swift */, - 06787C3A2AB82BDB008ABDD7 /* CrashReportViewController.swift */, 1E73F99D2C282822002BF649 /* SectionViewController-iPad.swift */, 1EFB545E2C32514000B8E51B /* SectionViewModel-iPad.swift */, 1EFB545C2C314A6800B8E51B /* BarkSplitViewController.swift */, @@ -625,7 +621,6 @@ 06F08EA329B098DD006AB9CA /* CryptoSettingManager.swift */, 0653677729B727A60038BDB8 /* CryptoSettingRelay.swift */, 06F08EA629B1DDFE006AB9CA /* Error+Extension.swift */, - 06F08EAB29B1DECD006AB9CA /* NSLocalizedString+Extension.swift */, 06E944742C07012E00AC86AB /* RealmConfiguration.swift */, 0687F2A72CCB791A00B2A52F /* UIFont+Extension.swift */, 06BCAE552CDB19260092867A /* GroupMuteSettingManager.swift */, @@ -1232,6 +1227,7 @@ 067AFB1C2E5D8BE300AE78E7 /* UNNotificationContent+Extension.swift in Sources */, 0687F2AA2CCB7FA500B2A52F /* UIFont+Extension.swift in Sources */, 0632CE2320EC9098003FDF46 /* NotificationViewController.swift in Sources */, + 069332222E6A8E3100F9387F /* String+Extension.swift in Sources */, 06BCAE572CDB19420092867A /* GroupMuteSettingManager.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1298,7 +1294,6 @@ 06E944762C07013000AC86AB /* RealmConfiguration.swift in Sources */, 06EF49152D682A99008B91D2 /* PushResponse.swift in Sources */, 0603706720E1E31600F4CA05 /* Defines.swift in Sources */, - 06787C3B2AB82BDB008ABDD7 /* CrashReportViewController.swift in Sources */, 064CAB9E256BE9090018155C /* PreviewCardCellViewModel.swift in Sources */, 065BE4552565055F002A8CA4 /* HomeViewModel.swift in Sources */, 062B98C3251B2762004562E7 /* BKButton.swift in Sources */, @@ -1333,7 +1328,6 @@ 06EF49172D682AC4008B91D2 /* OptionsProvider.swift in Sources */, 06F08EAF29B5D9FF006AB9CA /* HUD.swift in Sources */, 065AE76B2987777F00323230 /* ArchiveSettingRelay.swift in Sources */, - 06F08EAC29B1DECD006AB9CA /* NSLocalizedString+Extension.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1346,7 +1340,6 @@ 06E9447A2C0704E500AC86AB /* ImageDownloader.swift in Sources */, 06CF784C21C7A51200A052D7 /* NotificationService.swift in Sources */, 06FB04052C53575400F3A213 /* SharedDefines.swift in Sources */, - 06F08EAD29B1DED6006AB9CA /* NSLocalizedString+Extension.swift in Sources */, 067AFB1D2E5D8BED00AE78E7 /* UNNotificationContent+Extension.swift in Sources */, 0653677629B719BC0038BDB8 /* CryptoSettingManager.swift in Sources */, 06E9446F2C06FF1E00AC86AB /* BadgeProcessor.swift in Sources */, @@ -1357,6 +1350,7 @@ 06F08EA529B1DDA7006AB9CA /* Algorithm.swift in Sources */, 06E944782C0701F300AC86AB /* IconProcessor.swift in Sources */, 06BBB89125650CCF0076F63E /* ArchiveSettingManager.swift in Sources */, + 069332232E6A8E3100F9387F /* String+Extension.swift in Sources */, 06D69E412C11983E00161A35 /* CallProcessor.swift in Sources */, 06B11591247BC132006D91FB /* Message.swift in Sources */, 06E9447C2C07052F00AC86AB /* ImageProcessor.swift in Sources */, diff --git a/Bark/AppDelegate.swift b/Bark/AppDelegate.swift index 432340b..67f2451 100644 --- a/Bark/AppDelegate.swift +++ b/Bark/AppDelegate.swift @@ -53,10 +53,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD UNUserNotificationCenter.current().delegate = self var actions = [ - UNNotificationAction(identifier: "copy", title: NSLocalizedString("Copy2"), options: UNNotificationActionOptions.foreground) + UNNotificationAction(identifier: "copy", title: "Copy2".localized, options: UNNotificationActionOptions.foreground) ] if #available(iOSApplicationExtension 15.0, *) { - actions.append(UNNotificationAction(identifier: "mute", title: NSLocalizedString("muteGroup1Hour"), options: UNNotificationActionOptions.foreground)) + actions.append(UNNotificationAction(identifier: "mute", title: "muteGroup1Hour".localized, options: UNNotificationActionOptions.foreground)) } UNUserNotificationCenter.current().setNotificationCategories([ // customDismissAction 会在 clear 推送时,调起APP,这时可以顺便更新下 DeviceToken,防止过期。 @@ -171,7 +171,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD ServerManager.shared.addServer(server: server) ServerManager.shared.setCurrentServer(serverId: server.id) ServerManager.shared.syncAllServers() - HUDSuccess(NSLocalizedString("AddedSuccessfully")) + HUDSuccess("AddedSuccessfully".localized) } return true } @@ -188,14 +188,14 @@ extension AppDelegate { let url = try? (userInfo["url"] as? String)?.asURL() let alertController = UIAlertController(title: title, message: body, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("CopyContent"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "CopyContent".localized, style: .default, handler: { _ in if let copy = userInfo["copy"] as? String { UIPasteboard.general.string = copy } else { UIPasteboard.general.string = body } })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("MoreActions"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "MoreActions".localized, style: .default, handler: { _ in var shareContent = "" if let title = title { shareContent += "\(title)\n" @@ -226,7 +226,7 @@ extension AppDelegate { } controller?.present(activityController, animated: true, completion: nil) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) let viewController = Client.shared.currentSnackbarController diff --git a/Bark/Localizable.xcstrings b/Bark/Localizable.xcstrings index 3774afd..17fd607 100644 --- a/Bark/Localizable.xcstrings +++ b/Bark/Localizable.xcstrings @@ -814,6 +814,7 @@ } }, "Copy" : { + "extractionState" : "manual", "localizations" : { "en" : { "stringUnit" : { diff --git a/Common/Date+Extension.swift b/Common/Date+Extension.swift index ad44743..b0f39c5 100644 --- a/Common/Date+Extension.swift +++ b/Common/Date+Extension.swift @@ -33,14 +33,14 @@ extension Date { } if hour > 0 { if minute > 0 { - return String(format: NSLocalizedString("timeMinHourAgo"), hour, minute) + return "timeMinHourAgo".localized(with: hour, minute) } - return String(format: NSLocalizedString("timeHourAgo"), hour) + return "timeHourAgo".localized(with: hour) } if minute > 1 { - return String(format: NSLocalizedString("timeMinAgo"), minute) + return "timeMinAgo".localized(with: minute) } - return NSLocalizedString("timeJustNow") + return "timeJustNow".localized } } diff --git a/Common/NSLocalizedString+Extension.swift b/Common/NSLocalizedString+Extension.swift deleted file mode 100644 index 87dc0a4..0000000 --- a/Common/NSLocalizedString+Extension.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// NSLocalizedString+Extension.swift -// Bark -// -// Created by huangfeng on 2023/3/3. -// Copyright © 2023 Fin. All rights reserved. -// - -import Foundation - -func NSLocalizedString(_ key: String) -> String { - return NSLocalizedString(key, comment: "") -} diff --git a/Common/String+Extension.swift b/Common/String+Extension.swift index f7687c8..9638502 100644 --- a/Common/String+Extension.swift +++ b/Common/String+Extension.swift @@ -53,3 +53,13 @@ extension String { return String(format: self, arguments) } } + +extension String { + var localized: String { + return NSLocalizedString(self, comment: "") + } + + func localized(with arguments: CVarArg...) -> String { + return String(format: NSLocalizedString(self, comment: ""), arguments: arguments) + } +} diff --git a/Controller/BarkTabBarController.swift b/Controller/BarkTabBarController.swift index 4cb5832..d8160b9 100644 --- a/Controller/BarkTabBarController.swift +++ b/Controller/BarkTabBarController.swift @@ -20,9 +20,9 @@ class BarkTabBarController: StateStorageTabBarController { BarkNavigationController(rootViewController: MessageSettingsViewController(viewModel: MessageSettingsViewModel())) ] - let tabBarItems = [UITabBarItem(title: NSLocalizedString("service"), image: UIImage(named: "baseline_gite_black_24pt"), tag: 0), - UITabBarItem(title: NSLocalizedString("historyMessage"), image: Icon.history, tag: 1), - UITabBarItem(title: NSLocalizedString("settings"), image: UIImage(named: "baseline_manage_accounts_black_24pt"), tag: 2)] + let tabBarItems = [UITabBarItem(title: "service".localized, image: UIImage(named: "baseline_gite_black_24pt"), tag: 0), + UITabBarItem(title: "historyMessage".localized, image: Icon.history, tag: 1), + UITabBarItem(title: "settings".localized, image: UIImage(named: "baseline_manage_accounts_black_24pt"), tag: 2)] for (index, viewController) in self.viewControllers!.enumerated() { viewController.tabBarItem = tabBarItems[index] } diff --git a/Controller/CrashReportViewController.swift b/Controller/CrashReportViewController.swift deleted file mode 100644 index 1a7b2e6..0000000 --- a/Controller/CrashReportViewController.swift +++ /dev/null @@ -1,76 +0,0 @@ -// -// CrashReportViewController.swift -// Bark -// -// Created by huangfeng on 2023/9/18. -// Copyright © 2023 Fin. All rights reserved. -// - -import UIKit - -class CrashReportViewController: UIViewController { - var crashLog = "" - override func viewDidLoad() { - super.viewDidLoad() - self.overrideUserInterfaceStyle = .light - self.view.backgroundColor = UIColor.white - - let warningIcon = UIImageView(image: UIImage(named: "warning")) - self.view.addSubview(warningIcon) - - let crashedTitle = UILabel() - crashedTitle.text = NSLocalizedString("crashed") - crashedTitle.font = UIFont.preferredFont(ofSize: 30, weight: .bold) - crashedTitle.adjustsFontForContentSizeCategory = true - crashedTitle.textColor = UIColor(r255: 239, g255: 77, b255: 77) - self.view.addSubview(crashedTitle) - - let contentlabel = UITextView() - contentlabel.backgroundColor = UIColor.clear - contentlabel.isEditable = false - contentlabel.dataDetectorTypes = [.link] - contentlabel.isScrollEnabled = false - contentlabel.textContainerInset = .zero - contentlabel.textContainer.lineFragmentPadding = 0 - contentlabel.font = UIFont.preferredFont(ofSize: 14) - contentlabel.adjustsFontForContentSizeCategory = true - contentlabel.textColor = UIColor(r255: 51, g255: 51, b255: 51) - contentlabel.text = NSLocalizedString("crashContent") - self.view.addSubview(contentlabel) - - let copyButton = UIButton() - copyButton.titleLabel?.font = UIFont.preferredFont(ofSize: 16, weight: .bold) - copyButton.titleLabel?.adjustsFontForContentSizeCategory = true - copyButton.setTitleColor(UIColor.white, for: .normal) - copyButton.setTitle(NSLocalizedString("copyCrashLog"), for: .normal) - copyButton.backgroundColor = UIColor(r255: 239, g255: 77, b255: 77) - copyButton.clipsToBounds = true - copyButton.layer.cornerRadius = 6 - self.view.addSubview(copyButton) - - warningIcon.snp.makeConstraints { make in - make.top.equalTo(kSafeAreaInsets.top + 60) - make.left.equalTo(15) - make.width.height.equalTo(42) - } - crashedTitle.snp.makeConstraints { make in - make.left.equalTo(warningIcon.snp.right).offset(10) - make.centerY.equalTo(warningIcon) - } - contentlabel.snp.makeConstraints { make in - make.left.equalTo(20) - make.right.equalTo(-20) - make.top.equalTo(warningIcon.snp.bottom).offset(40) - } - copyButton.snp.makeConstraints { make in - make.left.right.equalTo(contentlabel) - make.top.equalTo(contentlabel.snp.bottom).offset(40) - make.height.equalTo(44) - } - - copyButton.rx.tap.subscribe { [weak self] _ in - UIPasteboard.general.string = self?.crashLog - ProgressHUD.inform(NSLocalizedString("Copy")) - }.disposed(by: rx.disposeBag) - } -} diff --git a/Controller/CryptoSettingController.swift b/Controller/CryptoSettingController.swift index a534ef0..5a398e5 100644 --- a/Controller/CryptoSettingController.swift +++ b/Controller/CryptoSettingController.swift @@ -18,7 +18,7 @@ class CryptoSettingController: BaseViewController { let textField = BorderTextField(title: "Key") textField.font = UIFont.preferredFont(ofSize: 14) textField.adjustsFontForContentSizeCategory = true - textField.placeholder = String(format: NSLocalizedString("enterKey"), 16) + textField.placeholder = "enterKey".localized(with: 16) return textField }() @@ -31,7 +31,7 @@ class CryptoSettingController: BaseViewController { let doneButton: BKButton = { let btn = BKButton() - btn.setTitle(NSLocalizedString("done"), for: .normal) + btn.setTitle("done".localized, for: .normal) btn.setTitleColor(BKColor.lightBlue.darken3, for: .normal) btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40) btn.fontSize = 14 @@ -40,7 +40,7 @@ class CryptoSettingController: BaseViewController { let copyButton: UIButton = { let btn = GradientButton() - btn.setTitle(NSLocalizedString("copyExample"), for: .normal) + btn.setTitle("copyExample".localized, for: .normal) btn.setTitleColor(UIColor.white, for: .normal) btn.titleLabel?.font = UIFont.preferredFont(ofSize: 14, weight: .medium) btn.titleLabel?.adjustsFontForContentSizeCategory = true @@ -62,7 +62,7 @@ class CryptoSettingController: BaseViewController { } override func makeUI() { - self.title = NSLocalizedString("encryptionSettings") + self.title = "encryptionSettings".localized self.navigationItem.setRightBarButtonItem(item: UIBarButtonItem(customView: doneButton)) self.view.addSubview(scrollView) @@ -79,8 +79,8 @@ class CryptoSettingController: BaseViewController { return label } - let algorithmLabel = getTitleLabel(title: NSLocalizedString("algorithm")) - let modeLabel = getTitleLabel(title: NSLocalizedString("mode")) + let algorithmLabel = getTitleLabel(title: "algorithm".localized) + let modeLabel = getTitleLabel(title: "mode".localized) let paddingLabel = getTitleLabel(title: "Padding") let keyLabel = getTitleLabel(title: "Key") let ivLabel = getTitleLabel(title: "Iv") @@ -226,7 +226,7 @@ class CryptoSettingController: BaseViewController { .disposed(by: rx.disposeBag) output.keyLengthChanged.drive(onNext: { [weak self] keyLength in - self?.keyTextField.placeholder = String(format: NSLocalizedString("enterKey"), keyLength) + self?.keyTextField.placeholder = "enterKey".localized(with: keyLength) }).disposed(by: rx.disposeBag) self.modeFeild @@ -246,7 +246,7 @@ class CryptoSettingController: BaseViewController { output.copy.drive(onNext: { text in UIPasteboard.general.string = text - HUDSuccess(NSLocalizedString("Copy")) + HUDSuccess("Copy".localized) }).disposed(by: rx.disposeBag) } @@ -255,7 +255,7 @@ class CryptoSettingController: BaseViewController { return } if let length = ["CBC": 16, "GCM": 12][mode] { - self.ivTextField.placeholder = String(format: NSLocalizedString("enterIv"), length) + self.ivTextField.placeholder = "enterIv".localized(with: length) } else { self.ivTextField.placeholder = "" } diff --git a/Controller/CryptoSettingViewModel.swift b/Controller/CryptoSettingViewModel.swift index ec08f84..f3491e7 100644 --- a/Controller/CryptoSettingViewModel.swift +++ b/Controller/CryptoSettingViewModel.swift @@ -96,7 +96,7 @@ class CryptoSettingViewModel: ViewModel, ViewModelType { let copy = Driver.combineLatest(copyScript, dependencies.deviceKey, dependencies.serverAddress) .compactMap { fields, deviceKey, serverAddress -> String? in guard fields.mode != "GCM" else { - showSnackbar.accept(NSLocalizedString("gcmNotSupported")) + showSnackbar.accept("gcmNotSupported".localized) return nil } let key = fields.key ?? "" @@ -105,7 +105,7 @@ class CryptoSettingViewModel: ViewModel, ViewModelType { """ #!/usr/bin/env bash - # Documentation: \(NSLocalizedString("encryptionUrl")) + # Documentation: \("encryptionUrl".localized) set -e @@ -114,22 +114,22 @@ class CryptoSettingViewModel: ViewModel, ViewModelType { # push payload json='{"body": "test", "sound": "birdsong"}' - # \(String(format: NSLocalizedString("keyComment"), Int(fields.algorithm.suffix(3))! / 8)) + # \("keyComment".localized(with: Int(fields.algorithm.suffix(3))! / 8)) ) key='\(key)' - # \(NSLocalizedString("ivComment")) + # \("ivComment".localized) iv='\(iv)' - # \(NSLocalizedString("opensslEncodingComment")) + # \("opensslEncodingComment".localized) key=$(printf $key | xxd -ps -c 200) iv=$(printf $iv | xxd -ps -c 200) - # \(NSLocalizedString("base64Notice")) + # \("base64Notice".localized) ciphertext=$(echo -n $json | openssl enc -aes-\(fields.algorithm.suffix(3))-\(fields.mode.lowercased()) -K $key \(iv.count > 0 ? "-iv $iv " : "")| base64) - # \(NSLocalizedString("consoleComment")) "\((try? AESCryptoModel(cryptoFields: fields).encrypt(text: "{\"body\": \"test\", \"sound\": \"birdsong\"}")) ?? "")" + # \("consoleComment".localized) "\((try? AESCryptoModel(cryptoFields: fields).encrypt(text: "{\"body\": \"test\", \"sound\": \"birdsong\"}")) ?? "")" echo $ciphertext - # \(NSLocalizedString("ciphertextComment")) + # \("ciphertextComment".localized) curl --data-urlencode "ciphertext=$ciphertext"\(iv.count == 0 ? "" : " --data-urlencode \"iv=\(iv)\"") \(serverAddress)/$deviceKey """ } diff --git a/Controller/HomeViewController.swift b/Controller/HomeViewController.swift index 3b6df74..e949d4c 100644 --- a/Controller/HomeViewController.swift +++ b/Controller/HomeViewController.swift @@ -1,5 +1,5 @@ // -// ViewController.swift +// HomeViewController.swift // Bark // // Created by huangfeng on 2018/3/7. @@ -19,7 +19,7 @@ class HomeViewController: BaseViewController { btn.setImage(Icon.add, for: .normal) btn.imageView?.tintColor = BKColor.grey.darken4 btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40) - btn.accessibilityIdentifier = NSLocalizedString("AddServer") + btn.accessibilityIdentifier = "AddServer".localized return btn }() @@ -28,12 +28,12 @@ class HomeViewController: BaseViewController { btn.setImage(UIImage(named: "baseline_filter_drama_black_24pt"), for: .normal) btn.imageView?.tintColor = BKColor.grey.darken4 btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40) - btn.accessibilityIdentifier = NSLocalizedString("serverList") + btn.accessibilityIdentifier = "serverList".localized return btn }() let startButton: FABButton = { - let button = FABButton(title: NSLocalizedString("RegisterDevice")) + let button = FABButton(title: "RegisterDevice".localized) button.backgroundColor = BKColor.grey.lighten5 button.transition([.scale(0.75), .opacity(0)]) return button @@ -184,7 +184,7 @@ class HomeViewController: BaseViewController { output.copy .drive(onNext: { [weak self] text in UIPasteboard.general.string = text - self?.showSnackbar(text: NSLocalizedString("Copy")) + self?.showSnackbar(text: "Copy".localized) }) .disposed(by: rx.disposeBag) @@ -228,14 +228,14 @@ class HomeViewController: BaseViewController { } func alertServerError(error: String) { - let alertController = UIAlertController(title: NSLocalizedString("ServerError"), message: error, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("faq"), style: .default, handler: { [weak self] _ in - guard let url = try? NSLocalizedString("faqUrl").asURL() else { + let alertController = UIAlertController(title: "ServerError".localized, message: error, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "faq".localized, style: .default, handler: { [weak self] _ in + guard let url = try? "faqUrl".localized.asURL() else { return } self?.navigationController?.present(BarkSFSafariViewController(url: url), animated: true, completion: nil) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) self.present(alertController, animated: true, completion: nil) } } diff --git a/Controller/HomeViewModel.swift b/Controller/HomeViewModel.swift index acda0b1..903c1f5 100644 --- a/Controller/HomeViewModel.swift +++ b/Controller/HomeViewModel.swift @@ -42,85 +42,85 @@ class HomeViewModel: ViewModel, ViewModelType { let previews: [PreviewModel] = [ PreviewModel( - body: NSLocalizedString("CustomedNotificationContent"), - notice: NSLocalizedString("Notice1") + body: "CustomedNotificationContent".localized, + notice: "Notice1".localized ), PreviewModel( - title: NSLocalizedString("CustomedNotificationTitle"), - body: NSLocalizedString("CustomedNotificationContent"), - notice: NSLocalizedString("Notice2") + title: "CustomedNotificationTitle".localized, + body: "CustomedNotificationContent".localized, + notice: "Notice2".localized ), PreviewModel( - body: NSLocalizedString("notificationSound"), - notice: NSLocalizedString("setSounds"), + body: "notificationSound".localized, + notice: "setSounds".localized, queryParameter: "sound=minuet", - moreInfo: NSLocalizedString("viewAllSounds"), + moreInfo: "viewAllSounds".localized, moreViewModel: SoundsViewModel() ), PreviewModel( - body: NSLocalizedString("ringtone"), - notice: NSLocalizedString("ringtoneNotice"), + body: "ringtone".localized, + notice: "ringtoneNotice".localized, queryParameter: "call=1" ), PreviewModel( - body: NSLocalizedString("archiveNotificationMessageTitle"), - notice: NSLocalizedString("archiveNotificationMessage"), + body: "archiveNotificationMessageTitle".localized, + notice: "archiveNotificationMessage".localized, queryParameter: "isArchive=1" ), PreviewModel( - body: NSLocalizedString("notificationIcon"), - notice: NSLocalizedString("notificationIconNotice"), + body: "notificationIcon".localized, + notice: "notificationIconNotice".localized, queryParameter: "icon=https://day.app/assets/images/avatar.jpg", image: UIImage(named: "icon") ), PreviewModel( - body: NSLocalizedString("messageGroup"), - notice: NSLocalizedString("groupMessagesNotice"), + body: "messageGroup".localized, + notice: "groupMessagesNotice".localized, queryParameter: "group=groupName", image: UIImage(named: "group") ), PreviewModel( - body: NSLocalizedString("pushNotificationEncryption"), - notice: NSLocalizedString("encryptionNotice"), + body: "pushNotificationEncryption".localized, + notice: "encryptionNotice".localized, queryParameter: "ciphertext=ciphertext", - moreInfo: NSLocalizedString("encryptionSettings"), + moreInfo: "encryptionSettings".localized, moreViewModel: CryptoSettingViewModel() ), PreviewModel( - body: NSLocalizedString("criticalAlert"), - notice: NSLocalizedString("criticalAlertNotice"), + body: "criticalAlert".localized, + notice: "criticalAlertNotice".localized, queryParameter: "level=critical&volume=5", image: UIImage(named: "criticalAlert") ), PreviewModel( - body: NSLocalizedString("interruptionLevel"), - notice: NSLocalizedString("interruptionLevelNotice"), + body: "interruptionLevel".localized, + notice: "interruptionLevelNotice".localized, queryParameter: "level=timeSensitive" ), PreviewModel( body: "URL Test", - notice: NSLocalizedString("urlParameter"), + notice: "urlParameter".localized, queryParameter: "url=https://www.baidu.com" ), PreviewModel( - body: NSLocalizedString("imagePushNotification"), - notice: NSLocalizedString("imageParameter"), + body: "imagePushNotification".localized, + notice: "imageParameter".localized, queryParameter: "image=https://day.app/assets/images/avatar.jpg" ), PreviewModel( body: "Copy Test", - notice: NSLocalizedString("copyParameter"), + notice: "copyParameter".localized, queryParameter: "copy=test", image: UIImage(named: "copyTest") ), PreviewModel( - body: NSLocalizedString("badge"), - notice: NSLocalizedString("badgeNotice"), + body: "badge".localized, + notice: "badgeNotice".localized, queryParameter: "badge=1" ), PreviewModel( - body: NSLocalizedString("automaticallyCopyTitle"), - notice: NSLocalizedString("automaticallyCopy"), + body: "automaticallyCopyTitle".localized, + notice: "automaticallyCopy".localized, queryParameter: "autoCopy=1©=optional" ) ] @@ -182,7 +182,7 @@ class HomeViewModel: ViewModel, ViewModelType { .skip(1) .compactMap { granted -> String? in if !granted { - return NSLocalizedString("AllowNotifications") + return "AllowNotifications".localized } return nil } @@ -204,7 +204,7 @@ class HomeViewModel: ViewModel, ViewModelType { case .ok: break case .serverError(let error): if serverErrorCount < 2 { - showSnackbar.accept("\(NSLocalizedString("ServerError")): \(error.rawString())") + showSnackbar.accept("\("ServerError".localized): \(error.rawString())") } else { alertServerError.accept(error.rawString()) } diff --git a/Controller/MessageListViewController.swift b/Controller/MessageListViewController.swift index 9f7a649..ee5c682 100644 --- a/Controller/MessageListViewController.swift +++ b/Controller/MessageListViewController.swift @@ -33,20 +33,20 @@ class MessageListViewController: BaseViewController { } subMenuElements.append(action) } - menuElements.append(UIMenu(title: NSLocalizedString("more"), children: subMenuElements)) + menuElements.append(UIMenu(title: "more".localized, children: subMenuElements)) let addNewMenu = UIMenu( - title: NSLocalizedString("clearFrom"), + title: "clearFrom".localized, children: menuElements ) let item = UIBarButtonItem(image: UIImage(named: "baseline_delete_outline_black_24pt"), menu: addNewMenu) - item.accessibilityLabel = NSLocalizedString("clear") + item.accessibilityLabel = "clear".localized return item } else { let btn = BKButton() btn.setImage(UIImage(named: "baseline_delete_outline_black_24pt"), for: .normal) btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40) - btn.accessibilityLabel = NSLocalizedString("clear") + btn.accessibilityLabel = "clear".localized return UIBarButtonItem(customView: btn) } @@ -246,10 +246,10 @@ class MessageListViewController: BaseViewController { output.errorAlert .drive(onNext: { [weak self] error in let alertController = UIAlertController(title: "Error", message: error, preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Copy2"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "Copy2".localized, style: .default, handler: { _ in UIPasteboard.general.string = error })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) self?.present(alertController, animated: true, completion: nil) }).disposed(by: rx.disposeBag) @@ -264,20 +264,20 @@ class MessageListViewController: BaseViewController { deleteBtn.rx.tap.subscribe(onNext: { [weak self] _ in guard let self else { return } - let alertController = UIAlertController(title: nil, message: NSLocalizedString("clearFrom"), preferredStyle: .actionSheet) - alertController.addAction(UIAlertAction(title: NSLocalizedString("lastHour"), style: .default, handler: { [weak self] _ in + let alertController = UIAlertController(title: nil, message: "clearFrom".localized, preferredStyle: .actionSheet) + alertController.addAction(UIAlertAction(title: "lastHour".localized, style: .default, handler: { [weak self] _ in self?.clearAlert(.lastHour) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("today"), style: .default, handler: { [weak self] _ in + alertController.addAction(UIAlertAction(title: "today".localized, style: .default, handler: { [weak self] _ in self?.clearAlert(.today) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("todayAndYesterday"), style: .default, handler: { [weak self] _ in + alertController.addAction(UIAlertAction(title: "todayAndYesterday".localized, style: .default, handler: { [weak self] _ in self?.clearAlert(.todayAndYesterday) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("allTime"), style: .default, handler: { [weak self] _ in + alertController.addAction(UIAlertAction(title: "allTime".localized, style: .default, handler: { [weak self] _ in self?.clearAlert(.allTime) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) if UIDevice.current.userInterfaceIdiom == .pad { alertController.modalPresentationStyle = .popover if #available(iOS 16.0, *) { @@ -291,11 +291,11 @@ class MessageListViewController: BaseViewController { } func clearAlert(_ range: MessageDeleteTimeRange) { - let alertController = UIAlertController(title: nil, message: "\(NSLocalizedString("clearFrom"))\n\(range.string)", preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("clear"), style: .destructive, handler: { [weak self] _ in + let alertController = UIAlertController(title: nil, message: "\("clearFrom".localized)\n\(range.string)", preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "clear".localized, style: .destructive, handler: { [weak self] _ in self?.clearRelay.accept(range) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) self.navigationController?.present(alertController, animated: true, completion: nil) } @@ -303,7 +303,7 @@ class MessageListViewController: BaseViewController { let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) // 复制 - alertController.addAction(UIAlertAction(title: NSLocalizedString("Copy2"), style: .default, handler: { [weak self] + alertController.addAction(UIAlertAction(title: "Copy2".localized, style: .default, handler: { [weak self] (_: UIAlertAction) in if #available(iOS 14.0, *) { var items = [[String: Any]]() @@ -315,10 +315,10 @@ class MessageListViewController: BaseViewController { } else { UIPasteboard.general.string = message.attributedText?.string ?? "" } - self?.showSnackbar(text: NSLocalizedString("Copy")) + self?.showSnackbar(text: "Copy".localized) })) // 删除 - alertController.addAction(UIAlertAction(title: NSLocalizedString("removeMessage"), style: .destructive, handler: { [weak self] + alertController.addAction(UIAlertAction(title: "removeMessage".localized, style: .destructive, handler: { [weak self] (_: UIAlertAction) in guard let self, let indexPath = self.tableView.indexPath(for: sourceCell) else { return } if sourceCell is MessageTableViewCell { @@ -330,7 +330,7 @@ class MessageListViewController: BaseViewController { } })) // 取消 - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: { _ in })) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: { _ in })) if UIDevice.current.userInterfaceIdiom == .pad { alertController.popoverPresentationController?.sourceView = sourceView.superview @@ -350,7 +350,7 @@ class MessageListViewController: BaseViewController { extension MessageListViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - let action = UIContextualAction(style: .destructive, title: NSLocalizedString("removeMessage")) { [weak self] _, _, actionPerformed in + let action = UIContextualAction(style: .destructive, title: "removeMessage".localized) { [weak self] _, _, actionPerformed in guard let self else { return } if self.tableView.cellForRow(at: indexPath) is MessageTableViewCell { @@ -361,12 +361,12 @@ extension MessageListViewController: UITableViewDelegate { } // 群组消息删除,弹出个确认提示 - let alertView = UIAlertController(title: nil, message: NSLocalizedString("removeNotice"), preferredStyle: .alert) - alertView.addAction(UIAlertAction(title: NSLocalizedString("removeMessage"), style: .destructive, handler: { _ in + let alertView = UIAlertController(title: nil, message: "removeNotice".localized, preferredStyle: .alert) + alertView.addAction(UIAlertAction(title: "removeMessage".localized, style: .destructive, handler: { _ in self.tableView.dataSource?.tableView?(self.tableView, commit: .delete, forRowAt: indexPath) actionPerformed(true) })) - alertView.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: { _ in + alertView.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: { _ in actionPerformed(false) })) self.present(alertView, animated: true, completion: nil) diff --git a/Controller/MessageListViewModel.swift b/Controller/MessageListViewModel.swift index 5ddb693..439abbd 100644 --- a/Controller/MessageListViewModel.swift +++ b/Controller/MessageListViewModel.swift @@ -176,7 +176,7 @@ class MessageListViewModel: ViewModel, ViewModelType { items.append(.message(model: messages[0])) } else if messages.count > 0 { // 多条消息时,折叠显示 - items.append(.messageGroup(name: group ?? NSLocalizedString("default"), totalCount: messageResult.count, messages: messages)) + items.append(.messageGroup(name: group ?? "default".localized, totalCount: messageResult.count, messages: messages)) } } return items @@ -212,7 +212,7 @@ class MessageListViewModel: ViewModel, ViewModelType { func transform(input: Input) -> Output { // 标题 - let titleRelay = BehaviorRelay(value: NSLocalizedString("historyMessage")) + let titleRelay = BehaviorRelay(value: "historyMessage".localized) // 数据源 let messagesRelay = BehaviorRelay<[MessageSection]>(value: []) // 刷新操作 @@ -232,9 +232,9 @@ class MessageListViewModel: ViewModel, ViewModelType { filterGroups .subscribe(onNext: { filterGroups in if filterGroups.count <= 0 { - titleRelay.accept(NSLocalizedString("historyMessage")) + titleRelay.accept("historyMessage".localized) } else { - titleRelay.accept(filterGroups.map { $0 ?? NSLocalizedString("default") }.joined(separator: " , ")) + titleRelay.accept(filterGroups.map { $0 ?? "default".localized }.joined(separator: " , ")) } }).disposed(by: rx.disposeBag) diff --git a/Controller/MessageSettingsViewController.swift b/Controller/MessageSettingsViewController.swift index 96bf578..22d062f 100644 --- a/Controller/MessageSettingsViewController.swift +++ b/Controller/MessageSettingsViewController.swift @@ -45,7 +45,7 @@ class MessageSettingsViewController: BaseViewController { lazy var addressTextField: TextField = { let textField = TextField() textField.keyboardType = .URL - textField.placeholder = NSLocalizedString("ServerAddress") - textField.detail = NSLocalizedString("ServerExample") + textField.placeholder = "ServerAddress".localized + textField.detail = "ServerExample".localized textField.transition([.scale(0.85), .opacity(0)]) textField.detailLabel.transition([.scale(0.85), .opacity(0)]) textField.textColor = BKColor.grey.darken4 @@ -42,7 +42,7 @@ class NewServerViewController: BaseViewController { let noticeLabel: UILabel = { let label = UILabel() - label.text = NSLocalizedString("DeploymentDocuments") + label.text = "DeploymentDocuments".localized label.textColor = BKColor.blue.base label.font = UIFont.preferredFont(ofSize: 12) label.adjustsFontForContentSizeCategory = true @@ -63,8 +63,8 @@ class NewServerViewController: BaseViewController { override func makeUI() { self.navigationItem.largeTitleDisplayMode = .never - navigationItem.title = NSLocalizedString("AddServer") - + navigationItem.title = "AddServer".localized + self.view.layout(addressTextField) .top(kNavigationHeight + 40).left(10).right(10) @@ -79,7 +79,7 @@ class NewServerViewController: BaseViewController { // 点击提醒按钮事件 let noticeTap = noticeLabel.gestureRecognizers!.first!.rx .event - .map { _ -> () in + .map { _ in () } .asDriver(onErrorJustReturn: ()) @@ -98,7 +98,7 @@ class NewServerViewController: BaseViewController { .asDriver(onErrorDriveWith: .empty()) // 扫描二维码事件 - let scannerDidScan = self.scanButton.rx.tap.flatMapLatest {[weak self] _ -> Observable in + let scannerDidScan = self.scanButton.rx.tap.flatMapLatest { [weak self] _ -> Observable in let controller = QRScannerViewController() self?.navigationController?.present(controller, animated: true, completion: nil) return controller.scannerDidSuccess @@ -116,8 +116,7 @@ class NewServerViewController: BaseViewController { output.showKeyboard.drive(onNext: { [weak self] show in if show { _ = self?.addressTextField.becomeFirstResponder() - } - else { + } else { self?.addressTextField.resignFirstResponder() } }).disposed(by: rx.disposeBag) diff --git a/Controller/NewServerViewModel.swift b/Controller/NewServerViewModel.swift index 0a17710..23bc43d 100644 --- a/Controller/NewServerViewModel.swift +++ b/Controller/NewServerViewModel.swift @@ -38,7 +38,7 @@ class NewServerViewModel: ViewModel, ViewModelType { let showSnackbar = PublishRelay() let notice = input.noticeClick - .map { URL(string: NSLocalizedString("deployUrl"))! } + .map { URL(string: "deployUrl".localized)! } .asDriver() input.viewDidAppear @@ -66,9 +66,8 @@ class NewServerViewModel: ViewModel, ViewModelType { return BarkApi.provider .request(.ping(baseURL: url)) .filterResponseError() - } - else { - showSnackbar.accept(NSLocalizedString("InvalidURL")) + } else { + showSnackbar.accept("InvalidURL".localized) return .empty() } } @@ -82,9 +81,9 @@ class NewServerViewModel: ViewModel, ViewModelType { ServerManager.shared.syncAllServers() strongSelf.pop.accept(URL(string: strongSelf.url)?.host ?? "") - showSnackbar.accept(NSLocalizedString("AddedSuccessfully")) + showSnackbar.accept("AddedSuccessfully".localized) case .failure(let error): - showSnackbar.accept("\(NSLocalizedString("InvalidServer"))\(error.rawString())") + showSnackbar.accept("\("InvalidServer".localized)\(error.rawString())") } }).disposed(by: rx.disposeBag) diff --git a/Controller/SectionViewModel-iPad.swift b/Controller/SectionViewModel-iPad.swift index 6ebada0..651c939 100644 --- a/Controller/SectionViewModel-iPad.swift +++ b/Controller/SectionViewModel-iPad.swift @@ -7,10 +7,10 @@ // import Foundation +import Material import RxCocoa import RxDataSources import RxSwift -import Material struct SectionItem { let image: UIImage? @@ -29,9 +29,9 @@ class SectionViewModel: ViewModel, ViewModelType { func initSectionItems() -> Observable<[SectionModel]> { let sectionItems = [ - SectionItem(image: UIImage(named: "baseline_gite_black_24pt"), title: NSLocalizedString("service")), - SectionItem(image: Icon.history, title: NSLocalizedString("historyMessage")), - SectionItem(image: UIImage(named: "baseline_manage_accounts_black_24pt"), title: NSLocalizedString("settings")), + SectionItem(image: UIImage(named: "baseline_gite_black_24pt"), title: "service".localized), + SectionItem(image: Icon.history, title: "historyMessage".localized), + SectionItem(image: UIImage(named: "baseline_manage_accounts_black_24pt"), title: "settings".localized) ] let section = [SectionModel(model: "", items: sectionItems)] return Observable.just(section) diff --git a/Controller/ServerListViewController.swift b/Controller/ServerListViewController.swift index 4d88862..f66b04f 100644 --- a/Controller/ServerListViewController.swift +++ b/Controller/ServerListViewController.swift @@ -40,7 +40,7 @@ class ServerListViewController: BaseViewController { closeButton.frame = CGRect(x: 0, y: 0, width: 40, height: 40) closeButton.hitTestSlop = UIEdgeInsets(top: -10, left: -10, bottom: -10, right: -10) closeButton.tintColor = BKColor.grey.darken4 - closeButton.accessibilityLabel = NSLocalizedString("close") + closeButton.accessibilityLabel = "close".localized return closeButton }() @@ -54,7 +54,7 @@ class ServerListViewController: BaseViewController { }() override func makeUI() { - self.title = NSLocalizedString("serverList") + self.title = "serverList".localized navigationItem.setRightBarButtonItem(item: UIBarButtonItem(customView: closeButton)) @@ -126,7 +126,7 @@ class ServerListViewController: BaseViewController { output.copy .drive(onNext: { [weak self] text in UIPasteboard.general.string = text - self?.showSnackbar(text: NSLocalizedString("Copy")) + self?.showSnackbar(text: "Copy".localized) }) .disposed(by: rx.disposeBag) @@ -148,50 +148,50 @@ class ServerListViewController: BaseViewController { } let alertController = UIAlertController(title: nil, message: "\(URL(string: viewModel.server.address)?.host ?? "")", preferredStyle: .actionSheet) - alertController.addAction(UIAlertAction(title: NSLocalizedString("copyAddressAndKey"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "copyAddressAndKey".localized, style: .default, handler: { _ in relay.accept((viewModel.server, .copy)) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("resetKey"), style: .default, handler: { _ in - let alertController = UIAlertController(title: NSLocalizedString("resetKey"), message: NSLocalizedString("resetKeyDesc"), preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "resetKey".localized, style: .default, handler: { _ in + let alertController = UIAlertController(title: "resetKey".localized, message: "resetKeyDesc".localized, preferredStyle: .alert) alertController.addTextField { textField in - textField.placeholder = NSLocalizedString("resetKeyPlaceholder") + textField.placeholder = "resetKeyPlaceholder".localized } - alertController.addAction(UIAlertAction(title: NSLocalizedString("confirm"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "confirm".localized, style: .default, handler: { _ in relay.accept((viewModel.server, .reset(key: alertController.textFields?.first?.text))) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) self.navigationController?.present(alertController, animated: true, completion: nil) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("setAsDefaultServer"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "setAsDefaultServer".localized, style: .default, handler: { _ in relay.accept((viewModel.server, .select)) })) - - alertController.addAction(UIAlertAction(title: NSLocalizedString("setServerName"), style: .default, handler: { _ in - let alertController = UIAlertController(title: NSLocalizedString("setServerName"), message: nil, preferredStyle: .alert) + + alertController.addAction(UIAlertAction(title: "setServerName".localized, style: .default, handler: { _ in + let alertController = UIAlertController(title: "setServerName".localized, message: nil, preferredStyle: .alert) alertController.addTextField { textField in textField.text = viewModel.server.name } - alertController.addAction(UIAlertAction(title: NSLocalizedString("confirm"), style: .default, handler: { _ in + alertController.addAction(UIAlertAction(title: "confirm".localized, style: .default, handler: { _ in relay.accept((viewModel.server, .setName(name: alertController.textFields?.first?.text))) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) self.navigationController?.present(alertController, animated: true, completion: nil) })) - - alertController.addAction(UIAlertAction(title: NSLocalizedString("deleteServer"), style: .destructive, handler: { _ in - let alertController = UIAlertController(title: nil, message: NSLocalizedString("confirmDeleteServer"), preferredStyle: .alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("confirm"), style: .destructive, handler: { _ in + alertController.addAction(UIAlertAction(title: "deleteServer".localized, style: .destructive, handler: { _ in + + let alertController = UIAlertController(title: nil, message: "confirmDeleteServer".localized, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "confirm".localized, style: .destructive, handler: { _ in relay.accept((viewModel.server, .delete)) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) self.navigationController?.present(alertController, animated: true, completion: nil) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel"), style: .cancel, handler: nil)) + alertController.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)) if UIDevice.current.userInterfaceIdiom == .pad { if let cell = self.tableView.cellForRow(at: indexPath) { diff --git a/Controller/ServerListViewModel.swift b/Controller/ServerListViewModel.swift index d00cef8..d4a45d2 100644 --- a/Controller/ServerListViewModel.swift +++ b/Controller/ServerListViewModel.swift @@ -54,7 +54,7 @@ class ServerListViewModel: ViewModel, ViewModelType { // 删除检查错误提示 deleteCheck.filter { $0 == nil } - .map { _ in NSLocalizedString("deleteFailed") } + .map { _ in "deleteFailed".localized } .bind(to: showSnackbar) .disposed(by: rx.disposeBag) @@ -79,7 +79,7 @@ class ServerListViewModel: ViewModel, ViewModelType { }.share() // 弹出删除提示 - serverDeleted.map { NSLocalizedString("deletedSuccessfully") } + serverDeleted.map { "deletedSuccessfully".localized } .bind(to: showSnackbar) .disposed(by: rx.disposeBag) @@ -90,7 +90,7 @@ class ServerListViewModel: ViewModel, ViewModelType { // 重置检查错误提示 resetServer.filter { ($0.2?.count ?? 0) <= 0 } - .map { _ in NSLocalizedString("resetFailed2") } + .map { _ in "resetFailed2".localized } .bind(to: showSnackbar) .disposed(by: rx.disposeBag) @@ -131,7 +131,7 @@ class ServerListViewModel: ViewModel, ViewModelType { // 重置失败提示 serverReseted.filter { $0 == nil } - .map { _ in NSLocalizedString("resetFailed") } + .map { _ in "resetFailed".localized } .bind(to: showSnackbar) .disposed(by: rx.disposeBag) @@ -153,7 +153,7 @@ class ServerListViewModel: ViewModel, ViewModelType { // 选择首页预览服务器 let serverSelected = input.selectServer.asObservable().map { server in ServerManager.shared.setCurrentServer(serverId: server.id) - showSnackbar.accept(NSLocalizedString("setSuccessfully")) + showSnackbar.accept("setSuccessfully".localized) return () } diff --git a/Controller/SoundsViewController.swift b/Controller/SoundsViewController.swift index 1b69aef..02f6cb0 100644 --- a/Controller/SoundsViewController.swift +++ b/Controller/SoundsViewController.swift @@ -26,13 +26,13 @@ class SoundsViewController: BaseViewController { // 上传铃声文件事件序列 let importSoundActionRelay = PublishRelay() - // 当前正在播放的音频资源ID - var currentSoundID: SystemSoundID = 0 - // 当前正在播放的音频文件ULRL - var playingAudio: CFURL? + // 当前正在播放的音频资源ID + var currentSoundID: SystemSoundID = 0 + // 当前正在播放的音频文件ULRL + var playingAudio: CFURL? override func makeUI() { - self.title = NSLocalizedString("notificationSound") + self.title = "notificationSound".localized self.view.addSubview(self.tableView) self.tableView.delegate = self @@ -82,28 +82,28 @@ class SoundsViewController: BaseViewController { output.copyNameAction.drive(onNext: { [unowned self] name in UIPasteboard.general.string = name.trimmingCharacters(in: .whitespacesAndNewlines) - self.navigationController?.showSnackbar(text: NSLocalizedString("Copy")) + self.navigationController?.showSnackbar(text: "Copy".localized) }).disposed(by: rx.disposeBag) output.playAction.drive(onNext: { url in - /// 先结束正在播放的音频 - AudioServicesDisposeSystemSoundID(self.currentSoundID) - /// 如果重复点击了当前音频,结束播放 - if self.playingAudio == url{ - self.playingAudio = nil - self.currentSoundID = 0 - return - } - self.playingAudio = url - AudioServicesCreateSystemSoundID(url, &self.currentSoundID) - AudioServicesPlaySystemSoundWithCompletion(self.currentSoundID) { - /// 判断是否是当前播放的音频,防止逻辑错误 - if self.playingAudio == url { - AudioServicesDisposeSystemSoundID(self.currentSoundID) - self.playingAudio = nil - self.currentSoundID = 0 - } - } + /// 先结束正在播放的音频 + AudioServicesDisposeSystemSoundID(self.currentSoundID) + /// 如果重复点击了当前音频,结束播放 + if self.playingAudio == url { + self.playingAudio = nil + self.currentSoundID = 0 + return + } + self.playingAudio = url + AudioServicesCreateSystemSoundID(url, &self.currentSoundID) + AudioServicesPlaySystemSoundWithCompletion(self.currentSoundID) { + /// 判断是否是当前播放的音频,防止逻辑错误 + if self.playingAudio == url { + AudioServicesDisposeSystemSoundID(self.currentSoundID) + self.playingAudio = nil + self.currentSoundID = 0 + } + } }).disposed(by: rx.disposeBag) output.pickerFile.drive(onNext: { [unowned self] _ in @@ -121,7 +121,7 @@ extension SoundsViewController: UITableViewDelegate { guard section == 0 else { return 0 } - return NSLocalizedString("uploadSoundNoticeFullText").count <= 30 ? 50 : 60 + return "uploadSoundNoticeFullText".localized.count <= 30 ? 50 : 60 } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { @@ -130,7 +130,7 @@ extension SoundsViewController: UITableViewDelegate { let view = UIView() let label = UILabel() - label.text = NSLocalizedString(sectionTitle) + label.text = sectionTitle.localized label.fontSize = 14 label.textColor = BKColor.grey.darken3 view.addSubview(label) @@ -147,9 +147,9 @@ extension SoundsViewController: UITableViewDelegate { return nil } let view = UIView() - - let fullText = NSLocalizedString("uploadSoundNoticeFullText") - let highlightText = NSLocalizedString("uploadSoundNoticeHighlightText") + + let fullText = "uploadSoundNoticeFullText".localized + let highlightText = "uploadSoundNoticeHighlightText".localized let attrStr = NSMutableAttributedString( string: fullText, attributes: [ diff --git a/Model/Algorithm.swift b/Model/Algorithm.swift index 1a3cde0..11beb03 100644 --- a/Model/Algorithm.swift +++ b/Model/Algorithm.swift @@ -62,7 +62,7 @@ struct AESCryptoModel { } guard algorithm.keyLength == key.count else { - throw String(format: NSLocalizedString("enterKey"), algorithm.keyLength) + throw String(format: "enterKey".localized, algorithm.keyLength) } var iv = "" @@ -74,9 +74,8 @@ struct AESCryptoModel { if let ivField = cryptoFields.iv, ivField.count == expectIVLength { iv = ivField - } - else { - throw String(format: NSLocalizedString("enterIv"), expectIVLength) + } else { + throw String(format: "enterIv".localized, expectIVLength) } } @@ -103,6 +102,6 @@ struct AESCryptoModel { } func decrypt(ciphertext: String) throws -> String { - return String(data: Data(try aes.decrypt(Array(base64: ciphertext))), encoding: .utf8) ?? "" + return try String(data: Data(aes.decrypt(Array(base64: ciphertext))), encoding: .utf8) ?? "" } } diff --git a/Model/MessageDeleteTimeRange.swift b/Model/MessageDeleteTimeRange.swift index c38919f..48262dc 100644 --- a/Model/MessageDeleteTimeRange.swift +++ b/Model/MessageDeleteTimeRange.swift @@ -32,23 +32,23 @@ enum MessageDeleteTimeRange { var string: String { switch self { case .lastHour: - return NSLocalizedString("lastHour") + return "lastHour".localized case .today: - return NSLocalizedString("today") + return "today".localized case .todayAndYesterday: - return NSLocalizedString("todayAndYesterday") + return "todayAndYesterday".localized case .lastMonth: - return NSLocalizedString("lastMonth") + return "lastMonth".localized case .allTime: - return NSLocalizedString("allTime") + return "allTime".localized case .beforeOneHour: - return NSLocalizedString("beforeAnHour") + return "beforeAnHour".localized case .beforeToday: - return NSLocalizedString("beforeToday") + return "beforeToday".localized case .beforeYesterday: - return NSLocalizedString("beforeYesterday") + return "beforeYesterday".localized case .beforeOneMonth: - return NSLocalizedString("beforeAMonth") + return "beforeAMonth".localized } } diff --git a/Model/MessageSection.swift b/Model/MessageSection.swift index dc27b6a..5cdb0ab 100644 --- a/Model/MessageSection.swift +++ b/Model/MessageSection.swift @@ -53,7 +53,7 @@ extension MessageListCellItem: IdentifiableType { case .message(let model): return "list_\(model.id)_\(model.createDate?.timeInterval ?? 0)" case .messageGroup(_, _, let messages): - return "group_\(messages.first?.group ?? NSLocalizedString("default"))_\(messages.first?.createDate?.timeInterval ?? 0)" + return "group_\(messages.first?.group ?? "default".localized)_\(messages.first?.createDate?.timeInterval ?? 0)" } } } diff --git a/View/AddSoundCell.swift b/View/AddSoundCell.swift index a255abf..9462c5b 100644 --- a/View/AddSoundCell.swift +++ b/View/AddSoundCell.swift @@ -11,7 +11,7 @@ import UIKit class AddSoundCell: UITableViewCell { let button: UIButton = { let button = UIButton(type: .system) - button.setTitle(NSLocalizedString("uploadSound"), for: .normal) + button.setTitle("uploadSound".localized, for: .normal) button.setImage(UIImage(named: "music_note-music_note_symbol"), for: .normal) button.setTitleColor(BKColor.lightBlue.darken3, for: .normal) button.tintColor = BKColor.lightBlue.darken3 @@ -31,8 +31,8 @@ class AddSoundCell: UITableViewCell { } } + @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - } diff --git a/View/ArchiveSettingCell.swift b/View/ArchiveSettingCell.swift index 35d28db..ae580ab 100644 --- a/View/ArchiveSettingCell.swift +++ b/View/ArchiveSettingCell.swift @@ -18,7 +18,7 @@ class ArchiveSettingCell: BaseTableViewCell { super.init(style: style, reuseIdentifier: reuseIdentifier) self.selectionStyle = .none self.backgroundColor = BKColor.background.secondary - self.textLabel?.text = NSLocalizedString("defaultArchiveSettings") + self.textLabel?.text = "defaultArchiveSettings".localized contentView.addSubview(switchButton) switchButton.snp.makeConstraints { make in diff --git a/View/MessageList/MessageGroupMoreView.swift b/View/MessageList/MessageGroupMoreView.swift index c18f27a..1395c24 100644 --- a/View/MessageList/MessageGroupMoreView.swift +++ b/View/MessageList/MessageGroupMoreView.swift @@ -25,7 +25,7 @@ class MessageGroupMoreView: UIView { var count: Int = 0 { didSet { - moreLabel.text = NSLocalizedString("viewAllMessages").format(count) + moreLabel.text = "viewAllMessages".localized(with: count) } } diff --git a/View/MessageList/MessageItemView.swift b/View/MessageList/MessageItemView.swift index dad012b..a239020 100644 --- a/View/MessageList/MessageItemView.swift +++ b/View/MessageList/MessageItemView.swift @@ -205,7 +205,7 @@ extension MessageItemView { .contentMode(.scaleAspectFit) ] if #available(iOS 14.0, *) { - options.append(.rightNavItemTitle(NSLocalizedString("save"), onTap: { [weak self] _ in + options.append(.rightNavItemTitle("save".localized, onTap: { [weak self] _ in // 保存 image 到相册 self?.saveImageToAlbum(image) })) @@ -248,7 +248,7 @@ extension MessageItemView { PHPhotoLibrary.requestAuthorization(for: .addOnly) { status in guard status == .authorized || status == .limited else { DispatchQueue.main.async { - SVProgressHUD.showInfo(withStatus: NSLocalizedString("noPermission")) + SVProgressHUD.showInfo(withStatus: "noPermission".localized) } return } @@ -257,7 +257,7 @@ extension MessageItemView { }) { success, error in DispatchQueue.main.async { if success { - SVProgressHUD.showSuccess(withStatus: NSLocalizedString("saveSuccess")) + SVProgressHUD.showSuccess(withStatus: "saveSuccess".localized) } else { SVProgressHUD.showError(withStatus: error?.localizedDescription) } diff --git a/View/MessageList/MessageTableViewCell.swift b/View/MessageList/MessageTableViewCell.swift index 950121d..aaec06c 100644 --- a/View/MessageList/MessageTableViewCell.swift +++ b/View/MessageList/MessageTableViewCell.swift @@ -107,7 +107,7 @@ class MessageGroupTableViewCell: UITableViewCell { if let newValue, !newValue.isEmpty { groupHeader.groupName = newValue } else { - groupHeader.groupName = NSLocalizedString("default") + groupHeader.groupName = "default".localized } } get { diff --git a/View/MessageList/ShowLessAndClearView.swift b/View/MessageList/ShowLessAndClearView.swift index 9e1b9a4..5664441 100644 --- a/View/MessageList/ShowLessAndClearView.swift +++ b/View/MessageList/ShowLessAndClearView.swift @@ -86,7 +86,7 @@ private class ShowLessView: UIView { let label = UILabel() label.font = UIFont.preferredFont(ofSize: 12) label.textColor = BKColor.grey.darken3 - label.text = NSLocalizedString("showLess") + label.text = "showLess".localized return label }() @@ -148,7 +148,7 @@ private class ClearView: UIView { let label = UILabel() label.font = UIFont.preferredFont(ofSize: 12) label.textColor = BKColor.grey.darken3 - label.text = NSLocalizedString("clear") + label.text = "clear".localized label.alpha = 0 return label }() diff --git a/View/MessageSettingFooter.swift b/View/MessageSettingFooter.swift index b5b097c..e1888ae 100644 --- a/View/MessageSettingFooter.swift +++ b/View/MessageSettingFooter.swift @@ -20,12 +20,12 @@ class MessageSettingFooter: UITextView, UITextViewDelegate { // build号 let buildVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "" - let attr = NSMutableAttributedString(string: "\(NSLocalizedString("version")) \(appVersion) (\(buildVersion))\n", attributes: [.font: UIFont.preferredFont(ofSize: 12), .foregroundColor: BKColor.grey.darken1]) - attr.append(NSAttributedString(string: NSLocalizedString("privacyPolicy"), attributes: [.link: "privacyPolicy"])) + let attr = NSMutableAttributedString(string: "\("version".localized) \(appVersion) (\(buildVersion))\n", attributes: [.font: UIFont.preferredFont(ofSize: 12), .foregroundColor: BKColor.grey.darken1]) + attr.append(NSAttributedString(string: "privacyPolicy".localized, attributes: [.link: "privacyPolicy"])) attr.append(NSAttributedString(string: " · ")) - attr.append(NSAttributedString(string: NSLocalizedString("userAgreement"), attributes: [.link: "userAgreement"])) + attr.append(NSAttributedString(string: "userAgreement".localized, attributes: [.link: "userAgreement"])) attr.append(NSAttributedString(string: " · ")) - attr.append(NSAttributedString(string: NSLocalizedString("restoreSubscription"), attributes: [.link: "restoreSubscription"])) + attr.append(NSAttributedString(string: "restoreSubscription".localized, attributes: [.link: "restoreSubscription"])) let style = NSMutableParagraphStyle() style.lineSpacing = 6 diff --git a/View/PreviewCardCell.swift b/View/PreviewCardCell.swift index f52b51f..3827700 100644 --- a/View/PreviewCardCell.swift +++ b/View/PreviewCardCell.swift @@ -12,13 +12,13 @@ import UIKit class PreviewCardCell: BaseTableViewCell { let previewButton: IconButton = { let button = IconButton(image: Icon.cm.skipForward, tintColor: BKColor.grey.base) - button.accessibilityLabel = NSLocalizedString("demo") + button.accessibilityLabel = "demo".localized return button }() let copyButton: IconButton = { let button = IconButton(image: UIImage(named: "baseline_file_copy_white_24pt"), tintColor: BKColor.grey.base) - button.accessibilityLabel = NSLocalizedString("copy") + button.accessibilityLabel = "copy".localized return button }() diff --git a/View/SoundCell.swift b/View/SoundCell.swift index 3a0c589..6282b8f 100644 --- a/View/SoundCell.swift +++ b/View/SoundCell.swift @@ -13,7 +13,7 @@ import UIKit class SoundCell: BaseTableViewCell { let copyButton: IconButton = { let button = IconButton(image: UIImage(named: "baseline_file_copy_white_24pt"), tintColor: BKColor.grey.base) - button.accessibilityLabel = NSLocalizedString("copy") + button.accessibilityLabel = "copy".localized return button }() diff --git a/View/iCloudStatusCell.swift b/View/iCloudStatusCell.swift index 51cf1b6..36c31c6 100644 --- a/View/iCloudStatusCell.swift +++ b/View/iCloudStatusCell.swift @@ -14,18 +14,18 @@ class iCloudStatusCell: UITableViewCell { super.init(style: .value1, reuseIdentifier: reuseIdentifier) self.selectionStyle = .none self.backgroundColor = BKColor.background.secondary - self.textLabel?.text = NSLocalizedString("iCloudSatatus") + self.textLabel?.text = "iCloudStatus".localized self.detailTextLabel?.text = "" self.detailTextLabel?.textColor = BKColor.grey.darken2 CKContainer.default().accountStatus { status, _ in dispatch_sync_safely_main_queue { switch status { case .available: - self.detailTextLabel?.text = NSLocalizedString("available") + self.detailTextLabel?.text = "available".localized case .noAccount, .restricted, .temporarilyUnavailable: - self.detailTextLabel?.text = NSLocalizedString("restricted") + self.detailTextLabel?.text = "restricted".localized case .couldNotDetermine: - self.detailTextLabel?.text = NSLocalizedString("unknown") + self.detailTextLabel?.text = "unknown".localized @unknown default: break } diff --git a/notificationContentExtension/NotificationViewController.swift b/notificationContentExtension/NotificationViewController.swift index 8321b7c..fa2ea00 100644 --- a/notificationContentExtension/NotificationViewController.swift +++ b/notificationContentExtension/NotificationViewController.swift @@ -95,7 +95,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi UIPasteboard.general.string = content } - showTips(text: NSLocalizedString("Copy", comment: "")) + showTips(text: "Copy".localized) completion(.doNotDismiss) } @@ -105,7 +105,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi // 静音一小时 GroupMuteSettingManager().settings[groupName] = Date() + 60 * 60 - showTips(text: String(format: NSLocalizedString("groupMuted", comment: ""), groupName.isEmpty ? "default" : groupName)) + showTips(text: String(format: "groupMuted".localized, groupName.isEmpty ? "default".localized : groupName)) completion(.doNotDismiss) }