mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00

* Translations workflow and tools * improved the name of the workflow * need this commit to trigger the workflow for the first time * swift tools can now run on CI * only strings and stringsdict will be committed * fixed a workflow issue * starting the workflow to save it * fixing downgrade issues * fixing URL usage * install localazy * fixing add-paths typo * downloaded strings * removing on push trigger * Update Tools/Sources/DownloadTranslations.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * Added locheck for string verification * code formatting improvement * Update Tools/Sources/Locheck.swift Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * pr suggestion --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
45 lines
1.3 KiB
Swift
45 lines
1.3 KiB
Swift
import ArgumentParser
|
|
import Foundation
|
|
|
|
struct Locheck: ParsableCommand {
|
|
enum LocheckError: LocalizedError {
|
|
case missingMint
|
|
case outputError
|
|
|
|
var errorDescription: String? {
|
|
switch self {
|
|
case .missingMint:
|
|
return "💥 Unable to find mint. Fix by running:\nbrew install mint\n"
|
|
case .outputError:
|
|
return "💥 Failed to read the output from locheck."
|
|
}
|
|
}
|
|
}
|
|
|
|
static var configuration = CommandConfiguration(abstract: "A tool that verifies bad strings contained in localization files")
|
|
|
|
private var stringsDirectoryURL: URL {
|
|
Utilities.projectDirectoryURL.appendingPathComponent("ElementX/Resources/Localizations")
|
|
}
|
|
|
|
func run() throws {
|
|
try checkMint()
|
|
try checkStrings()
|
|
}
|
|
|
|
func checkStrings() throws {
|
|
guard let output = try Utilities.zsh("mint run locheck discoverlproj --ignore-missing --ignore lproj_file_missing_from_translation --treat-warnings-as-errors \(stringsDirectoryURL.path)") else {
|
|
throw LocheckError.missingMint
|
|
}
|
|
print(output)
|
|
}
|
|
|
|
private func checkMint() throws {
|
|
let result = try Utilities.zsh("which mint")
|
|
|
|
if result?.contains("not found") == true {
|
|
throw LocheckError.missingMint
|
|
}
|
|
}
|
|
}
|