Skip to content

Commit

Permalink
better error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalPineapple committed Feb 27, 2024
1 parent 0f9261b commit 4b78383
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Scripts/ValidateLocalizedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,18 @@ let translationRegex = Regex {
var allValid = true

for filePath in stringsFiles {
let translationKeys = try String(contentsOfFile: filePath).matches(of: translationRegex).map { $0.1 }
let translationKeys = try Set(String(contentsOfFile: filePath).matches(of: translationRegex).map { $0.1 })

if Set(translationKeys) != localizedKeysSet {
if translationKeys != localizedKeysSet {
print("\(filePath) does not match expected set of localized string keys")
let expected = translationKeys.subtracting(localizedKeysSet)
if expected.count != 0 {
print("Expected Keys not found: \(expected)")
}
let found = localizedKeysSet.subtracting(translationKeys)
if found.count != 0 {
print("No translation found for keys: \(found)")
}
allValid = false
}
}
Expand Down

0 comments on commit 4b78383

Please sign in to comment.