From c805a8e820cf3bede0f707838d6e705b80c864d9 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Tue, 26 Dec 2023 14:26:17 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Fix=20new=20SwiftLint?= =?UTF-8?q?=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/.swiftlint.yml | 3 +-- sources/LocalizationEditor/AppDelegate.swift | 4 +++- .../LocalizationEditor/Extensions/NSView+Localization.swift | 3 ++- .../LocalizationEditor/Providers/LocalizationProvider.swift | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) mode change 100644 => 100755 sources/.swiftlint.yml diff --git a/sources/.swiftlint.yml b/sources/.swiftlint.yml old mode 100644 new mode 100755 index 4e885a4..e86f3dc --- a/sources/.swiftlint.yml +++ b/sources/.swiftlint.yml @@ -14,8 +14,7 @@ analyzer_rules: number_separator: minimum_length: 7 -opt_in_rules: - - anyobject_protocol +opt_in_rules: - closure_end_indentation - closure_spacing - collection_alignment diff --git a/sources/LocalizationEditor/AppDelegate.swift b/sources/LocalizationEditor/AppDelegate.swift index c8beeb4..1346a01 100644 --- a/sources/LocalizationEditor/AppDelegate.swift +++ b/sources/LocalizationEditor/AppDelegate.swift @@ -5,14 +5,16 @@ // Created by Igor Kulman on 30/05/2018. // Copyright © 2018 Igor Kulman. All rights reserved. // -// swiftlint:disable private_outlet import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { + + // swiftlint:disable private_outlet @IBOutlet weak var openFolderMenuItem: NSMenuItem! @IBOutlet weak var reloadMenuItem: NSMenuItem! + // swiftlint:enable private_outlet private var editorWindow: NSWindow? { return NSApp.windows.first(where: { $0.windowController is WindowController }) diff --git a/sources/LocalizationEditor/Extensions/NSView+Localization.swift b/sources/LocalizationEditor/Extensions/NSView+Localization.swift index 2d86583..ed26bbb 100644 --- a/sources/LocalizationEditor/Extensions/NSView+Localization.swift +++ b/sources/LocalizationEditor/Extensions/NSView+Localization.swift @@ -7,7 +7,6 @@ // // Inspired by https://github.com/PiXeL16/IBLocalizable for iOS // -// swiftlint:disable unused_setter_value import AppKit import Foundation @@ -45,7 +44,9 @@ extension NSCell: Localizable { get { return "" } + // swiftlint:disable unused_setter_value set {} + // swiftlint:enable unused_setter_value } /// Applies the localizable string to the localizable field of the supported view diff --git a/sources/LocalizationEditor/Providers/LocalizationProvider.swift b/sources/LocalizationEditor/Providers/LocalizationProvider.swift index 9c5220e..cf76c60 100644 --- a/sources/LocalizationEditor/Providers/LocalizationProvider.swift +++ b/sources/LocalizationEditor/Providers/LocalizationProvider.swift @@ -49,7 +49,7 @@ final class LocalizationProvider { private func writeToFile(localization: Localization) { let data = localization.translations.map { string -> String in let stringForMessage: String - if let newMessage = string.message, newMessage.replacingOccurrences(of: " ", with: "") != "" { + if let newMessage = string.message, !newMessage.replacingOccurrences(of: " ", with: "").isEmpty { stringForMessage = "\n/* \(newMessage) */\n" } else { stringForMessage = "" From d3f1a0d27068a01789630eefe26797caa63362a5 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Tue, 26 Dec 2023 15:12:36 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=A7=20Update=20project=20to=20late?= =?UTF-8?q?st=20Xcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/LocalizationEditor.xcodeproj/project.pbxproj | 9 ++++++++- .../xcshareddata/xcschemes/LocalizationEditor.xcscheme | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/LocalizationEditor.xcodeproj/project.pbxproj b/sources/LocalizationEditor.xcodeproj/project.pbxproj index 07e0e99..e81d22b 100644 --- a/sources/LocalizationEditor.xcodeproj/project.pbxproj +++ b/sources/LocalizationEditor.xcodeproj/project.pbxproj @@ -171,7 +171,9 @@ F3D9C94320BEC7460081830A /* Products */, F3D9C96F20BEF0730081830A /* Frameworks */, ); + indentWidth = 4; sourceTree = ""; + tabWidth = 4; }; F3D9C94320BEC7460081830A /* Products */ = { isa = PBXGroup; @@ -351,8 +353,9 @@ F3D9C93A20BEC7460081830A /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 1010; - LastUpgradeCheck = 1410; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = "Igor Kulman"; TargetAttributes = { F3D9C94120BEC7460081830A = { @@ -548,6 +551,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -583,6 +587,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -610,6 +615,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -645,6 +651,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; diff --git a/sources/LocalizationEditor.xcodeproj/xcshareddata/xcschemes/LocalizationEditor.xcscheme b/sources/LocalizationEditor.xcodeproj/xcshareddata/xcschemes/LocalizationEditor.xcscheme index 30acad7..19e42e1 100644 --- a/sources/LocalizationEditor.xcodeproj/xcshareddata/xcschemes/LocalizationEditor.xcscheme +++ b/sources/LocalizationEditor.xcodeproj/xcshareddata/xcschemes/LocalizationEditor.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 26 Dec 2023 15:16:34 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=E2=9C=A8=20Make=20tab=20and=20shift+tab=20?= =?UTF-8?q?move=20to=20the=20next=20or=20previous=20row?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Cells/LocalizationCell.swift | 4 +- .../UI/ViewController.swift | 43 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/sources/LocalizationEditor/UI/Cells/LocalizationCell.swift b/sources/LocalizationEditor/UI/Cells/LocalizationCell.swift index b48a000..4877d1f 100644 --- a/sources/LocalizationEditor/UI/Cells/LocalizationCell.swift +++ b/sources/LocalizationEditor/UI/Cells/LocalizationCell.swift @@ -9,6 +9,7 @@ import Cocoa protocol LocalizationCellDelegate: AnyObject { + func controlTextDidEndEditing(_ obj: Notification) func userDidUpdateLocalizationString(language: String, key: String, with value: String, message: String?) } @@ -58,7 +59,8 @@ final class LocalizationCell: NSTableCellView { // MARK: - Delegate extension LocalizationCell: NSTextFieldDelegate { - func controlTextDidEndEditing(_: Notification) { + func controlTextDidEndEditing(_ obj: Notification) { + delegate?.controlTextDidEndEditing(obj) guard let language = language, let value = value else { return } diff --git a/sources/LocalizationEditor/UI/ViewController.swift b/sources/LocalizationEditor/UI/ViewController.swift index ba5149e..a74981d 100644 --- a/sources/LocalizationEditor/UI/ViewController.swift +++ b/sources/LocalizationEditor/UI/ViewController.swift @@ -196,6 +196,49 @@ extension ViewController: LocalizationCellDelegate { func userDidUpdateLocalizationString(language: String, key: String, with value: String, message: String?) { dataSource.updateLocalization(language: language, key: key, with: value, message: message) } + + func controlTextDidEndEditing(_ obj: Notification) { + guard let view = obj.object as? NSView, let textMovementInt = obj.userInfo?["NSTextMovement"] as? Int, let textMovement = NSTextMovement(rawValue: textMovementInt) else { + return + } + + let columnIndex = tableView.column(for: view) + let rowIndex = tableView.row(for: view) + + let newRowIndex: Int + let newColumnIndex: Int + + switch textMovement { + case .tab: + if columnIndex + 1 >= tableView.numberOfColumns - 1 { + newRowIndex = rowIndex + 1 + newColumnIndex = 1 + } else { + newColumnIndex = columnIndex + 1 + newRowIndex = rowIndex + } + if newRowIndex >= tableView.numberOfRows { + return + } + case .backtab: + if columnIndex - 1 <= 0 { + newRowIndex = rowIndex - 1 + newColumnIndex = tableView.numberOfColumns - 2 + } else { + newColumnIndex = columnIndex - 1 + newRowIndex = rowIndex + } + if newRowIndex < 0 { + return + } + default: + return + } + + DispatchQueue.main.async { [weak self] in + self?.tableView.editColumn(newColumnIndex, row: newRowIndex, with: nil, select: true) + } + } } // MARK: - ActionsCellDelegate From 6170a3c5cee4fa2744474d9dcd71a5fc1fa7e37d Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Tue, 26 Dec 2023 20:47:01 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=94=96=20Update=20version=20to=202.9.?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/LocalizationEditor.xcodeproj/project.pbxproj | 4 ++-- sources/LocalizationEditor/Info.plist | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/LocalizationEditor.xcodeproj/project.pbxproj b/sources/LocalizationEditor.xcodeproj/project.pbxproj index e81d22b..e406865 100644 --- a/sources/LocalizationEditor.xcodeproj/project.pbxproj +++ b/sources/LocalizationEditor.xcodeproj/project.pbxproj @@ -686,7 +686,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; - MARKETING_VERSION = 2.9.1; + MARKETING_VERSION = 2.9.2; PRODUCT_BUNDLE_IDENTIFIER = sk.kulman.LocalizationEditor; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -711,7 +711,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; - MARKETING_VERSION = 2.9.1; + MARKETING_VERSION = 2.9.2; PRODUCT_BUNDLE_IDENTIFIER = sk.kulman.LocalizationEditor; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/sources/LocalizationEditor/Info.plist b/sources/LocalizationEditor/Info.plist index 047d7cf..d6101c3 100644 --- a/sources/LocalizationEditor/Info.plist +++ b/sources/LocalizationEditor/Info.plist @@ -34,7 +34,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 319 + 324 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright From ea8af79355efb8eeadc5c1f77e13381b53aa2b6d Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Thu, 4 Jan 2024 11:23:03 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/README.md b/README.md index 957ae58..abe91d1 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,7 @@

Localization Editor

-

- - License: MIT - - - Platforms - - - Swift Version - - - Twitter: @igorkulman - - Buy Me A Coffee -

+ Simple macOS editor app to help you manage iOS app localizations by allowing you to edit all the translations side by side, highlighting missing translations