Files
Morgan Pretty a32af018a7 Refactored the LintLocalizableStrings script
• Added new 'LintControl' mechanisms to allow for ignoring sections of code
• Added new 'MatchType' mechanisms for excluding unlocalized cases
• Updated the code to explicitly handle localized template strings (both single and multiline)
• Updated the code to process files across multiple threads to improve performance
• Updated the code to use Swift 5.7 regex and store in static variables to prevent reconstruction every time they are used
• Removed the list of individual files which are ignored (now just output a count)
• Fixed an issue where having a localized string on a subsequent line could result in an unlocalized (or incorrectly localized) string not being detected
• Fixed an issue where having multiple strings on a single line could result in an unlocalized string not being detected
• Fixed an issue where zero-width characters would result in the variable count comparison between translations failing
• Fixed a number of localization warnings
2024-10-18 10:19:38 +11:00

64 lines
1.7 KiB
Swift

// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
public struct Version: Comparable {
public let major: Int
public let minor: Int
public let patch: Int
// stringlint:ignore_contents
public var stringValue: String { "\(major).\(minor).\(patch)" }
// MARK: - Initialization
public init(
major: Int,
minor: Int,
patch: Int
) {
self.major = major
self.minor = minor
self.patch = patch
}
// MARK: - Functions
// stringlint:ignore_contents
public static func from(_ versionString: String) -> Version {
var tokens: [Int] = versionString
.split(separator: ".")
.map { (Int($0) ?? 0) }
// Extend to '{major}.{minor}.{patch}' if any parts were omitted
while tokens.count < 3 {
tokens.append(0)
}
return Version(major: tokens[0], minor: tokens[1], patch: tokens[2])
}
// MARK: - Comparable
public static func == (lhs: Version, rhs: Version) -> Bool {
return (
lhs.major == rhs.major &&
lhs.minor == rhs.minor &&
lhs.patch == rhs.patch
)
}
public static func < (lhs: Version, rhs: Version) -> Bool {
guard lhs.major == rhs.major else { return (lhs.major < rhs.major) }
guard lhs.minor == rhs.minor else { return (lhs.minor < rhs.minor) }
return (lhs.patch < rhs.patch)
}
}
public enum FeatureVersion: Int, Codable, Equatable, Hashable, DatabaseValueConvertible {
case legacyDisappearingMessages
case newDisappearingMessages
}